Documentation ¶
Index ¶
- Constants
- type BcReactorFSM
- func (fsm *BcReactorFSM) FirstTwoBlocks() (first, second *types.Block, err error)
- func (fsm *BcReactorFSM) Handle(msg *bcReactorMessage) error
- func (fsm *BcReactorFSM) NeedsBlocks() bool
- func (fsm *BcReactorFSM) SetLogger(l log.Logger)
- func (fsm *BcReactorFSM) Start()
- func (fsm *BcReactorFSM) Status() (height, maxPeerHeight int64)
- type BlockData
- type BlockPool
- func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, blockSize int) error
- func (pool *BlockPool) BlockAndPeerAtHeight(height int64) (bData *BlockData, err error)
- func (pool *BlockPool) Cleanup()
- func (pool *BlockPool) FirstTwoBlocksAndPeers() (first, second *BlockData, err error)
- func (pool *BlockPool) InvalidateFirstTwoBlocks(err error)
- func (pool *BlockPool) MakeNextRequests(maxNumRequests int)
- func (pool *BlockPool) NeedsBlocks() bool
- func (pool *BlockPool) NumPeers() int
- func (pool *BlockPool) ProcessedCurrentHeightBlock()
- func (pool *BlockPool) ReachedMaxHeight() bool
- func (pool *BlockPool) RemovePeer(peerID p2p.ID, err error)
- func (pool *BlockPool) RemovePeerAtCurrentHeights(err error)
- func (pool *BlockPool) SetLogger(l log.Logger)
- func (pool *BlockPool) UpdatePeer(peerID p2p.ID, base int64, height int64) error
- type BlockchainReactor
- func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)
- func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
- func (bcR *BlockchainReactor) OnStart() error
- func (bcR *BlockchainReactor) OnStop()
- func (bcR *BlockchainReactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte)
- func (bcR *BlockchainReactor) ReceiveEnvelope(e p2p.Envelope)
- func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (bcR *BlockchainReactor) SetLogger(l log.Logger)
- func (bcR *BlockchainReactor) SwitchToFastSync(state sm.State) error
- type BpPeer
- func (peer *BpPeer) AddBlock(block *types.Block, recvSize int) error
- func (peer *BpPeer) BlockAtHeight(height int64) (*types.Block, error)
- func (peer *BpPeer) CheckRate() error
- func (peer *BpPeer) Cleanup()
- func (peer *BpPeer) RemoveBlock(height int64)
- func (peer *BpPeer) RequestSent(height int64)
- func (peer *BpPeer) SetLogger(l log.Logger)
- func (peer *BpPeer) String() string
- type BpPeerParams
Constants ¶
const ( // BlockchainChannel is a channel for blocks and status updates (`BlockStore` height) BlockchainChannel = byte(0x40) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BcReactorFSM ¶
type BcReactorFSM struct {
// contains filtered or unexported fields
}
BcReactorFSM is the datastructure for the Blockchain Reactor State Machine
func NewFSM ¶
func NewFSM(height int64, toBcR bcReactor) *BcReactorFSM
NewFSM creates a new reactor FSM.
func (*BcReactorFSM) FirstTwoBlocks ¶
func (fsm *BcReactorFSM) FirstTwoBlocks() (first, second *types.Block, err error)
FirstTwoBlocks returns the two blocks at pool height and height+1
func (*BcReactorFSM) Handle ¶
func (fsm *BcReactorFSM) Handle(msg *bcReactorMessage) error
Handle processes messages and events sent to the FSM.
func (*BcReactorFSM) NeedsBlocks ¶
func (fsm *BcReactorFSM) NeedsBlocks() bool
NeedsBlocks checks if more block requests are required.
func (*BcReactorFSM) SetLogger ¶
func (fsm *BcReactorFSM) SetLogger(l log.Logger)
SetLogger sets the FSM logger.
func (*BcReactorFSM) Status ¶
func (fsm *BcReactorFSM) Status() (height, maxPeerHeight int64)
Status returns the pool's height and the maximum peer height.
type BlockData ¶
type BlockData struct {
// contains filtered or unexported fields
}
BlockData stores the peer responsible to deliver a block and the actual block if delivered.
type BlockPool ¶
type BlockPool struct { Height int64 // height of next block to execute MaxPeerHeight int64 // maximum height of all peers // contains filtered or unexported fields }
BlockPool keeps track of the fast sync peers, block requests and block responses.
func NewBlockPool ¶
NewBlockPool creates a new BlockPool.
func (*BlockPool) AddBlock ¶
AddBlock validates that the block comes from the peer it was expected from and stores it in the 'blocks' map.
func (*BlockPool) BlockAndPeerAtHeight ¶
BlockAndPeerAtHeight retrieves the block and delivery peer at specified height. Returns errMissingBlock if a block was not found
func (*BlockPool) FirstTwoBlocksAndPeers ¶
FirstTwoBlocksAndPeers returns the blocks and the delivery peers at pool's height H and H+1.
func (*BlockPool) InvalidateFirstTwoBlocks ¶
InvalidateFirstTwoBlocks removes the peers that sent us the first two blocks, blocks are removed by RemovePeer().
func (*BlockPool) MakeNextRequests ¶
MakeNextRequests creates more requests if the block pool is running low.
func (*BlockPool) NeedsBlocks ¶
NeedsBlocks returns true if more blocks are required.
func (*BlockPool) ProcessedCurrentHeightBlock ¶
func (pool *BlockPool) ProcessedCurrentHeightBlock()
ProcessedCurrentHeightBlock performs cleanup after a block is processed. It removes block at pool height and the peers that are now short.
func (*BlockPool) ReachedMaxHeight ¶
ReachedMaxHeight check if the pool has reached the maximum peer height.
func (*BlockPool) RemovePeer ¶
RemovePeer removes the blocks and requests from the peer, reschedules them and deletes the peer.
func (*BlockPool) RemovePeerAtCurrentHeights ¶
RemovePeerAtCurrentHeights checks if a block at pool's height H exists and if not, it removes the delivery peer and returns. If a block at height H exists then the check and peer removal is done for H+1. This function is called when the FSM is not able to make progress for some time. This happens if either the block H or H+1 have not been delivered.
type BlockchainReactor ¶
type BlockchainReactor struct { p2p.BaseReactor // contains filtered or unexported fields }
BlockchainReactor handles long-term catchup syncing.
func NewBlockchainReactor ¶
func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, fastSync bool) *BlockchainReactor
NewBlockchainReactor returns new reactor instance.
func (*BlockchainReactor) AddPeer ¶
func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)
AddPeer implements Reactor by sending our state to peer.
func (*BlockchainReactor) GetChannels ¶
func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor
func (*BlockchainReactor) OnStart ¶
func (bcR *BlockchainReactor) OnStart() error
OnStart implements service.Service.
func (*BlockchainReactor) OnStop ¶
func (bcR *BlockchainReactor) OnStop()
OnStop implements service.Service.
func (*BlockchainReactor) Receive ¶
func (bcR *BlockchainReactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte)
func (*BlockchainReactor) ReceiveEnvelope ¶ added in v0.34.23
func (bcR *BlockchainReactor) ReceiveEnvelope(e p2p.Envelope)
Receive implements Reactor by handling 4 types of messages (look below).
func (*BlockchainReactor) RemovePeer ¶
func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
RemovePeer implements Reactor by removing peer from the pool.
func (*BlockchainReactor) SetLogger ¶
func (bcR *BlockchainReactor) SetLogger(l log.Logger)
SetLogger implements service.Service by setting the logger on reactor and pool.
func (*BlockchainReactor) SwitchToFastSync ¶ added in v0.34.0
func (bcR *BlockchainReactor) SwitchToFastSync(state sm.State) error
SwitchToFastSync is called by the state sync reactor when switching to fast sync.
type BpPeer ¶
type BpPeer struct { ID p2p.ID Base int64 // the peer reported base Height int64 // the peer reported height NumPendingBlockRequests int // number of requests still waiting for block responses // contains filtered or unexported fields }
BpPeer is the datastructure associated with a fast sync peer.
func NewBpPeer ¶
func NewBpPeer(peerID p2p.ID, base int64, height int64, onErr func(err error, peerID p2p.ID), params *BpPeerParams) *BpPeer
NewBpPeer creates a new peer.
func (*BpPeer) AddBlock ¶
AddBlock adds a block at peer level. Block must be non-nil and recvSize a positive integer The peer must have a pending request for this block.
func (*BpPeer) BlockAtHeight ¶
BlockAtHeight returns the block at a given height if available and errMissingBlock otherwise.
func (*BpPeer) CheckRate ¶
CheckRate verifies that the response rate of the peer is acceptable (higher than the minimum allowed).
func (*BpPeer) Cleanup ¶
func (peer *BpPeer) Cleanup()
Cleanup performs cleanup of the peer, removes blocks, requests, stops timer and monitor.
func (*BpPeer) RemoveBlock ¶
RemoveBlock removes the block of given height
func (*BpPeer) RequestSent ¶
RequestSent records that a request was sent, and starts the peer timer and monitor if needed.
type BpPeerParams ¶
type BpPeerParams struct {
// contains filtered or unexported fields
}
BpPeerParams stores the peer parameters that are used when creating a peer.
func BpPeerDefaultParams ¶
func BpPeerDefaultParams() *BpPeerParams
BpPeerDefaultParams returns the default peer parameters.