<p>You're correct: the <a href="https://github.com/bitcoin/bitcoin" rel="nofollow">Bitcoin Core master branch</a> no longer sends the <code>getblocks</code> message because it uses headers-first synchronization to get all the headers (with the <code>getheaders</code> message), allowing it to hash the headers itself, verify their proof-of-work, and request the corresponding blocks in parallel from multiple peers with <code>getdata</code> messages.  I believe the upcoming version 0.10 branch is supposed to be forked off of the master branch later today.  (Will update answer with link when that happens.)</p>

<p>Here are some direct code links:</p>

<ul>
<li><p>Bitcoin Core 0.9.3 sends the <code>getblocks</code> message with <a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L2575" rel="nofollow">this line</a>.  That function is <a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L2506" rel="nofollow">defined here</a>.</p></li>
<li><p>In the master branch, this is <a href="https://github.com/bitcoin/bitcoin/commit/341735eb8f42e898cf9d4d130709471e5d01abe2#diff-7ec3c68a81efff79b6ca22ac1f1eabbaL2508" rel="nofollow">the patch that replaced the line above</a></p></li>
</ul>

<p>Bitcoin Core version 0.10 will continue to process the <code>getblocks</code> message from remote peers, as you note.</p>

CC BY-SA 3.0
2014-11-18T13:20:33.367Z
I really appreciate your answer. Thank you very much, David.
Eleven
CC BY-SA 3.0
2014-11-18T15:14:01.387Z
Hi David,one point confused me. Is it in parallel that requesting the corresponding blocks with getdata messages. I think it is in a single thread. We can get at most 16 blocks from one peer and then iterate another peer. Is it right?  Thank you
Eleven
CC BY-SA 3.0
2014-11-18T15:39:36.510Z
@Eleven The headers-first pull linked in the answer says, "Blocks are fetched in parallel from all available outbound peers, using a limited moving window. When one peer stalls the movement of the window, it is disconnected."  I haven't reviewed that code yet, but if you find something that contradicts that statement, let me know and I'll update the answer.  Thanks!
David A. Harding
CC BY-SA 3.0
2014-11-18T12:54:48.520Z
2014-11-18T12:54:48.520Z
David A. Harding
<p>I am reading the protocol part. One silly question. I found the part processing getblocks part, but i did not find when and where to send the getblocks command.Or it is deleted in the new bitcoin edition.  Any idea, I will appreciate it very much. </p>

<bitcoind><protocol>
where is the code about sending command getblocks in bitcoin source code
Eleven
# where is the code about sending command getblocks in bitcoin source code

(Asked by: username_0 on 2014-11-18)

I am reading the protocol part. One silly question. I found the part processing getblocks part, but i did not find when and where to send the getblocks command.Or it is deleted in the new bitcoin edition. Any idea, I will appreciate it very much.

**Tags:** bitcoind, protocol


---

## 1 answers

### Answer by username_1 on 2014-11-18. Score: 3

You're correct: the [Bitcoin Core master branch](https://github.com/bitcoin/bitcoin) no longer sends the `getblocks` message because it uses headers-first synchronization to get all the headers (with the `getheaders` message), allowing it to hash the headers itself, verify their proof-of-work, and request the corresponding blocks in parallel from multiple peers with `getdata` messages. I believe the upcoming version 0.10 branch is supposed to be forked off of the master branch later today. (Will update answer with link when that happens.)

Here are some direct code links:

* Bitcoin Core 0.9.3 sends the `getblocks` message with [this line](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L2575). That function is [defined here](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L2506).
* In the master branch, this is [the patch that replaced the line above](https://github.com/bitcoin/bitcoin/commit/341735eb8f42e898cf9d4d130709471e5d01abe2#diff-7ec3c68a81efff79b6ca22ac1f1eabbaL2508)

Bitcoin Core version 0.10 will continue to process the `getblocks` message from remote peers, as you note.

> **Comments:**
> **username_0**: I really appreciate your answer. Thank you very much, username_1.  
> **username_0**: Hi username_1,one point confused me. Is it in parallel that requesting the corresponding blocks with getdata messages. I think it is in a single thread. We can get at most 16 blocks from one peer and then iterate another peer. Is it right?  Thank you  
> **username_1**: @username_0 The headers-first pull linked in the answer says, "Blocks are fetched in parallel from all available outbound peers, using a limited moving window. When one peer stalls the movement of the window, it is disconnected."  I haven't reviewed that code yet, but if you find something that contradicts that statement, let me know and I'll update the answer.  Thanks!  

---

