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


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 (https://github.com/bitcoin/bitcoin/blob/0.10/src/main.cpp#L3888).

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".

| improve this answer | |
  • 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 Jun 3 '15 at 13:02
  • Check L3892 (github.com/bitcoin/bitcoin/blob/0.10/src/main.cpp#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: bitcoin.org/en/developer-reference#getblocks and you could also follow the CNodes hashContinue variable. – Jonas Schnelli Jun 3 '15 at 13:23
  • Ok, but upon reading bitcoin.org/en/developer-reference#getblocks, 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 Jun 3 '15 at 13:38
  • 1
    I 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 Jun 3 '15 at 14:47
  • Yes I also think we're talking of different things. I'm actually referring to bitcoin.org/en/developer-reference#getblocks and in particular to bitcoin.org/img/dev/en-ibd-getblocks.svg 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 Jun 3 '15 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.