getheaders

The getheaders message requests a headers message that provides block headers starting from a particular point in the block chain. It allows a peer which has been disconnected or started for the first time to get the headers it hasn’t seen yet.

The “getheaders” message is nearly identical to the “getblocks” message, with one minor difference: the inv reply to the “getblocks” message will include no more than 500 block header hashes; the headers reply to the “getheaders” message will include as many as 2,000 block headers.

Name

Data Type

Bytes

Description

version

uint32

4

The protocol version number; the same as sent in the “version” message.

hash count

CompactSize

Varies

The number of header hashes provided not including the stop hash. There is no limit except that the byte size of the entire message must be below the “MAX_SIZE” limit; typically from 1 to 200 hashes are sent.

block header hashes

uint256[]

Varies

One or more block header hashes (32 bytes each) in internal byte order. Hashes should be provided in reverse order of block height, so highest-height hashes are listed first and lowest-height hashes are listed last.

stop hash

uint256

32

The header hash of the last header hash being requested; set to all zeroes to request an “inv” message with all subsequent header hashes (a maximum of 2000 will be sent as a reply to this message; if you need more than 2000, you will need to send another “getheaders” message with a higher-height header hash as the first entry in block header hash field).