<p>Block locator hashes are just the hashes of various blocks that you already have. As a new peer, the only block that you will have is the genesis block (the genesis block must be hard coded into your software). So you just send a <code>getheaders</code> message that only contains the hash of the genesis block.</p>

CC BY-SA 4.0
2019-05-15T15:36:30.040Z
2019-05-15T15:36:30.040Z
Ava Chow
<p>I'm trying to build my own block explorer
So that I need to use p2p bitcoin protocol. For that I'm using <a href="https://github.com/btcsuite/btcd/tree/master/peer" rel="nofollow noreferrer">btcd</a> (golang) lib.</p>

<p>According to <a href="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch08.asciidoc#address_propagation" rel="nofollow noreferrer">bitcoin book</a> I have to send <strong>version</strong> message (and receive <strong>verack</strong> message back) to init the connection, then I will send <strong>getheaders</strong> message in cycle.</p>

<p>Now, imagine I am a new peer and want to download all the blockchain (actually I want to receive block hashes with <strong>getheaders</strong> (2000 per tick) and for each block hash I want to receive a block itself to process it and put blocks data in my mongo database)</p>

<p>If I am new peer in the network, how should I send first (and next) <strong>getheaders</strong> message, I don't quite understand where should I get <strong>block locator hashes</strong> and how to form the message?</p>

<peers><peer-discovery><p2p>
P2P getHeaders message - how to get block locator hashes
newbie
# P2P getHeaders message - how to get block locator hashes

(Asked by: username_0 on 2019-05-15)

I'm trying to build my own block explorer
So that I need to use p2p bitcoin protocol. For that I'm using [btcd](https://github.com/btcsuite/btcd/tree/master/peer) (golang) lib.

According to [bitcoin book](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch08.asciidoc#address_propagation) I have to send **version** message (and receive **verack** message back) to init the connection, then I will send **getheaders** message in cycle.

Now, imagine I am a new peer and want to download all the blockchain (actually I want to receive block hashes with **getheaders** (2000 per tick) and for each block hash I want to receive a block itself to process it and put blocks data in my mongo database)

If I am new peer in the network, how should I send first (and next) **getheaders** message, I don't quite understand where should I get **block locator hashes** and how to form the message?

**Tags:** peers, peer-discovery, p2p


---

## 1 answers

### Answer by username_1 on 2019-05-15. Score: 2 | Accepted answer

Block locator hashes are just the hashes of various blocks that you already have. As a new peer, the only block that you will have is the genesis block (the genesis block must be hard coded into your software). So you just send a `getheaders` message that only contains the hash of the genesis block.


---

