where is the code about sending command getblocks in bitcoin source code

1

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.

Eleven

Posted 2014-11-18T10:34:12.170

Reputation: 187

Answers

3

You're correct: the Bitcoin Core master branch 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 version 0.10 will continue to process the getblocks message from remote peers, as you note.

David A. Harding

Posted 2014-11-18T10:34:12.170

Reputation: 10 154

1I really appreciate your answer. Thank you very much, David.Eleven 2014-11-18T13:20:33.367

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 youEleven 2014-11-18T15:14:01.387

@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 2014-11-18T15:39:36.510