const ( // BlockchainChannel is a channel for blocks and status updates (`BlockStore` height) BlockchainChannel = byte(0x40) )
RegisterBlockchainMessages registers the fast sync messages for amino encoding.
BlockPool keeps track of the fast sync peers, block requests and block responses.
func NewBlockPool(start int64, requestsCh chan<- BlockRequest, errorsCh chan<- peerError) *BlockPool
NewBlockPool returns a new BlockPool with the height equal to start. Block requests and errors will be sent to requestsCh and errorsCh accordingly.
AddBlock validates that the block comes from the peer it was expected from and calls the requester to store it. TODO: ensure that blocks come in order for each peer.
GetStatus returns pool's height, numPending requests and the number of requesters.
IsCaughtUp returns true if this node is caught up, false - otherwise. TODO: relax conditions, prevent abuse.
MaxPeerHeight returns the highest reported height.
OnStart implements cmn.Service by spawning requesters routine and recording pool's start time.
PeekTwoBlocks returns blocks at pool.height and pool.height+1. We need to see the second block's Commit to validate the first block. So we peek two blocks at a time. The caller will verify the commit.
PopRequest pops the first block at pool.height. It must have been validated by 'second'.Commit from PeekTwoBlocks().
RedoRequest invalidates the block at pool.height, Remove the peer and redo request from others. Returns the ID of the removed peer.
RemovePeer removes the peer with peerID from the pool. If there's no peer with peerID, function is a no-op.
SetPeerHeight sets the peer's alleged blockchain height.
BlockRequest stores a block request identified by the block Height and the PeerID responsible for delivering the block
BlockchainMessage is a generic message for this reactor.
BlockchainReactor handles long-term catchup syncing.
func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, fastSync bool) *BlockchainReactor
NewBlockchainReactor returns new reactor instance.
AddPeer implements Reactor by sending our state to peer.
BroadcastStatusRequest broadcasts `BlockStore` height.
GetChannels implements Reactor
OnStart implements cmn.Service.
OnStop implements cmn.Service.
Receive implements Reactor by handling 4 types of messages (look below).
RemovePeer implements Reactor by removing peer from the pool.
SetLogger implements cmn.Service by setting the logger on reactor and pool.