Amount of block locator hashes in "getblocks" message


How many block locator hashes are sent in a getblocks message? And how distant are these locator hashes from one another?

Aliakbar Ahmadi

Posted 2015-06-02T18:23:22.210

Reputation: 1 415



getblocks message pushes a maximum of 500 block invs to the caller. It will lookup the given block locater in the active chain and pushes up to 500 MSG_BLOCK invs to the caller (it might stop earlier because the called node reaches the chain tip). The corresponding code for bitcoin-core 0.10 can be found here (

Also notice that bitcoin-core now uses the headers first approach and therefore getblocks is no longer in use when acting as a "calling node".

Jonas Schnelli

Posted 2015-06-02T18:23:22.210

Reputation: 5 718

What was actually confusing me was teh description on Bitcoin Wiki, here. According to this description I imagine block locators being like distant markers on a blockchain - not being pushed into inv necessarily consecutively. Let's say one node0's last seen block was block #40 and the best tip is at block #45. Will node0 then send block locators/header hashes in its getblocks message in this pattern [#1, #2, #3, ..., #40]? or as "distant" markers like e.g. [#10, #25, #30, #35, ..., #40]?

– Aliakbar Ahmadi – 2015-06-03T13:02:41.060

Check L3892 ( As far as i see only one locator is supported. So your node0 should send its top block hash within the getheaders message. Consider also reading: and you could also follow the CNodes hashContinue variable.

– Jonas Schnelli – 2015-06-03T13:23:27.843

Ok, but upon reading, it says "One or more block header hashes ..." and with your hint of hashContinue and the fact that nLimit is decremented I'd claim that a consecutive order of multiple header hashes inside the inventory field sounds more plausible!? – Aliakbar Ahmadi – 2015-06-03T13:38:28.013

1I think you/we mix up getblocks message with the inv response. The getblocks message should probably only contain one block locater and a optional hash stop. The called node will response your getblocks message with serval invs containing all blockhashes that where found on the called node after your given block locater up to hash-stop or a max. of 500 blocks. If the node already sent you a block hash inv, it might be skipped. nLimit is decremented to make sure you won't get more than 500invs. – Jonas Schnelli – 2015-06-03T14:47:45.830

Yes I also think we're talking of different things. I'm actually referring to and in particular to where it also says "header hashes" whereas you say "The getblocks message should probably only contain one block locater and a optional hash stop."

– Aliakbar Ahmadi – 2015-06-03T14:54:29.260

What do you think? – Aliakbar Ahmadi – 2015-06-04T09:58:18.973