Skip to content

Header flooding

Christopher Schinnerl requested to merge header-broadcast into master

Created by: VoidingWarranties

This PR implements header broadcasting.

I tried to keep the changes to existing consensus code as minimal as possible. The only real changes to existing code should be:

  • validateHeader renamed to validateHeaderAndBlock
  • AcceptBlock and threadedReceiveBlocks broadcast blocks to some peers and headers to others, depending on their versions.

Everything else is new code and only deals with header broadcasting.

RelayHeader RPC mirrors the RelayBlock RPC used for block flooding. Every call to RelayBlock is also replaced with a branching broadcast that broadcasts RelayHeader to new peers (v0.5.2 and newer) and RelayBlock to old peers.

managedAcceptHeader mirrors managedAcceptBlock and does all of the header validation. However, unlike its counterpart, it cannot accept anything into the blockchain as it does not have the block and header-first blockchain downloads haven't been implemented yet. Instead, it returns nil if the header is valid. It is then up to the caller of managedAcceptHeader ( RelayHeader) to download the block and call either managedAcceptBlock or AcceptBlock on it.

Send1Blk is analogous to SendBlocks, but for just one block. It is used to download a block corresponding to a validated block header. Peers can request blocks from other peers by the block id. The requesting peer then calls AcceptBlock on the received block.

I tried to keep the commits clean and separated, so going through the diffs commit by commit should be easy.

Merge request reports