Request: Get Blocks (“getblocks”)
Request the sequence of blocks that occur after a specific block. If the specified block is on the server's most-work chain, the server responds with inv messages identifying up to 500 of the next blocks on that chain. If the specified block is not on the most-work chain, the server uses block information in the locator structure to determine the fork point and provides inv messages from that point.
Message Format
| Field | Length | Format | Description |
|---|---|---|---|
| locator | variable | vector of 32 byte block hash identifiers | identifies the desired blocks location in the blockchain |
| stop at hash | 32 bytes | bytes | send no more INVs if this hash is encountered |
Locator
See getheaders for a detailed description of the Locator object.
The response will begin at the child of the first hash in the locator list that matches a block hash identifier held by the responder. If no hashes match, the responder treats the genesis block as the fork point, so the response begins at block 1.
A locator MUST NOT contain more than 101 hashes; Bitcoin Cash Node disconnects peers that send a larger locator.
Use an empty locator to get an inv for block 1, and getheaders that block to discover the genesis block hash in the prevBlock field
Stop At Hash
The sender will stop sending inventory if it encounters this hash; the block with this hash is not included (unlike getheaders, which includes it). If the hash is never encountered, the sender will stop after 500 block inventory entries or when it hits the blockchain tip.