Documentation ¶
Index ¶
- Constants
- Variables
- type BlockPool
- func (pool *BlockPool) AddBlock(peerID p2p.NodeID, block *types.Block, blockSize int)
- func (pool *BlockPool) GetStatus() (height int64, numPending int32, lenRequesters int)
- func (pool *BlockPool) IsCaughtUp() bool
- func (pool *BlockPool) LastAdvance() time.Time
- func (pool *BlockPool) MaxPeerHeight() int64
- func (pool *BlockPool) OnStart() error
- func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)
- func (pool *BlockPool) PopRequest()
- func (pool *BlockPool) RedoRequest(height int64) p2p.NodeID
- func (pool *BlockPool) RemovePeer(peerID p2p.NodeID)
- func (pool *BlockPool) SetPeerRange(peerID p2p.NodeID, base int64, height int64)
- type BlockRequest
- type Reactor
Constants ¶
const ( // BlockchainChannel is a channel for blocks and status updates BlockchainChannel = p2p.ChannelID(0x40) )
Variables ¶
var ( // ChannelShims contains a map of ChannelDescriptorShim objects, where each // object wraps a reference to a legacy p2p ChannelDescriptor and the corresponding // p2p proto.Message the new p2p Channel is responsible for handling. // // // TODO: Remove once p2p refactor is complete. // ref: https://github.com/soominhyunwoo/tendermint/issues/5670 ChannelShims = map[p2p.ChannelID]*p2p.ChannelDescriptorShim{ BlockchainChannel: { MsgType: new(bcproto.Message), Descriptor: &p2p.ChannelDescriptor{ ID: byte(BlockchainChannel), Priority: 5, SendQueueCapacity: 1000, RecvBufferCapacity: 50 * 4096, RecvMessageCapacity: bc.MaxMsgSize, MaxSendBytes: 100, }, }, } )
Functions ¶
This section is empty.
Types ¶
type BlockPool ¶
type BlockPool struct { service.BaseService // contains filtered or unexported fields }
BlockPool keeps track of the fast sync peers, block requests and block responses.
func NewBlockPool ¶
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.
func (*BlockPool) AddBlock ¶
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.
func (*BlockPool) GetStatus ¶
GetStatus returns pool's height, numPending requests and the number of requesters.
func (*BlockPool) IsCaughtUp ¶
IsCaughtUp returns true if this node is caught up, false - otherwise.
func (*BlockPool) LastAdvance ¶
LastAdvance returns the time when the last block was processed (or start time if no blocks were processed).
func (*BlockPool) MaxPeerHeight ¶
MaxPeerHeight returns the highest reported height.
func (*BlockPool) OnStart ¶
OnStart implements service.Service by spawning requesters routine and recording pool's start time.
func (*BlockPool) PeekTwoBlocks ¶
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.
func (*BlockPool) PopRequest ¶
func (pool *BlockPool) PopRequest()
PopRequest pops the first block at pool.height. It must have been validated by 'second'.Commit from PeekTwoBlocks().
func (*BlockPool) RedoRequest ¶
RedoRequest invalidates the block at pool.height, Remove the peer and redo request from others. Returns the ID of the removed peer.
func (*BlockPool) RemovePeer ¶
RemovePeer removes the peer with peerID from the pool. If there's no peer with peerID, function is a no-op.
type BlockRequest ¶
BlockRequest stores a block request identified by the block Height and the PeerID responsible for delivering the block.
type Reactor ¶
type Reactor struct { service.BaseService // contains filtered or unexported fields }
BlockchainReactor handles long-term catchup syncing.
func NewReactor ¶
func NewReactor( logger log.Logger, state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, consReactor consensusReactor, blockchainCh *p2p.Channel, peerUpdates *p2p.PeerUpdates, fastSync bool, ) (*Reactor, error)
NewReactor returns new reactor instance.
func (*Reactor) OnStart ¶
OnStart starts separate go routines for each p2p Channel and listens for envelopes on each. In addition, it also listens for peer updates and handles messages on that p2p channel accordingly. The caller must be sure to execute OnStop to ensure the outbound p2p Channels are closed.
If fastSync is enabled, we also start the pool and the pool processing goroutine. If the pool fails to start, an error is returned.