P2P getHeaders message

by newbie   Last Updated May 15, 2019 12:27 PM

I'm trying to build my own block explorer So that I need to use p2p bitcoin protocol. For that I'm using btcd (golang) lib.

According to bitcoin book 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?



Related Questions


Updated November 21, 2017 12:27 PM

Updated October 13, 2017 11:27 AM

Updated September 13, 2018 14:27 PM

Updated September 09, 2017 09:27 AM

Updated December 09, 2017 15:27 PM