What happens when hash_stop
contains a hash that the node that receives the getblocks
/getheaders
message doesn't have, or does, but that hash (that is, the block whose hash it is) is somewhere earlier in the chain (behind the hash in block locator)? Is the maximum number of elements (childs) then returned, which is 500 for getblocks
and 2000 for getheaders
?
Asked
Active
Viewed 95 times
0

Cosmos
- 199
- 7
1 Answers
1
getheaders
only checks that hash_stop
is part of the main chain if locator
is empty. If it is, then it returns just that particular block header.
getblocks
does not do any validation on hash_stop
.
Both getheaders
and getblocks
will compare the block hashes exactly, so it only stops when it either reaches the limit, or sees a block hash that exactly matches hash_stop
. If the hash_stop
is not in the main chain after locator
, then the maximum number of items will be returned.

Ava Chow
- 70,382
- 5
- 81
- 161
getheaders
, by settinghash_count
to 0 and then providing hash (which representshash_stop
) is a way to obtain just one concrete header of some block? Before we could only get the whole block. – Cosmos Dec 21 '23 at 02:15hash_stop
then you would get just that header. There is nohash_count
. – Ava Chow Dec 21 '23 at 04:01getheaders
/getblocks
messages, according to bitcoin wiki, includeshash_count
(https://en.bitcoin.it/wiki/Protocol_documentation#getheaders). Bitcoin for developers also mentionshash_count
(https://developer.bitcoin.org/reference/p2p_networking.html#getblocks) – Cosmos Dec 21 '23 at 09:10hash_count
. It's just part of the serialization for a block locator object. – Ava Chow Dec 21 '23 at 13:59