tendermint: github.com/tendermint/tendermint/blockchain/v1 Index | Files

package v1

import "github.com/tendermint/tendermint/blockchain/v1"


Package Files

codec.go peer.go pool.go reactor.go reactor_fsm.go


const (
    // BlockchainChannel is a channel for blocks and status updates (`BlockStore` height)
    BlockchainChannel = byte(0x40)

func RegisterBlockchainMessages Uses

func RegisterBlockchainMessages(cdc *amino.Codec)

RegisterBlockchainMessages registers the fast sync messages for amino encoding.

type BcReactorFSM Uses

type BcReactorFSM struct {
    // contains filtered or unexported fields

BcReactorFSM is the datastructure for the Blockchain Reactor State Machine

func NewFSM Uses

func NewFSM(height int64, toBcR bcReactor) *BcReactorFSM

NewFSM creates a new reactor FSM.

func (*BcReactorFSM) FirstTwoBlocks Uses

func (fsm *BcReactorFSM) FirstTwoBlocks() (first, second *types.Block, err error)

FirstTwoBlocks returns the two blocks at pool height and height+1

func (*BcReactorFSM) Handle Uses

func (fsm *BcReactorFSM) Handle(msg *bcReactorMessage) error

Handle processes messages and events sent to the FSM.

func (*BcReactorFSM) NeedsBlocks Uses

func (fsm *BcReactorFSM) NeedsBlocks() bool

NeedsBlocks checks if more block requests are required.

func (*BcReactorFSM) SetLogger Uses

func (fsm *BcReactorFSM) SetLogger(l log.Logger)

SetLogger sets the FSM logger.

func (*BcReactorFSM) Start Uses

func (fsm *BcReactorFSM) Start()

Start starts the FSM.

func (*BcReactorFSM) Status Uses

func (fsm *BcReactorFSM) Status() (height, maxPeerHeight int64)

Status returns the pool's height and the maximum peer height.

type BlockData Uses

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 Uses

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 Uses

func NewBlockPool(height int64, toBcR bcReactor) *BlockPool

NewBlockPool creates a new BlockPool.

func (*BlockPool) AddBlock Uses

func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, blockSize int) error

AddBlock validates that the block comes from the peer it was expected from and stores it in the 'blocks' map.

func (*BlockPool) BlockAndPeerAtHeight Uses

func (pool *BlockPool) BlockAndPeerAtHeight(height int64) (bData *BlockData, err error)

BlockAndPeerAtHeight retrieves the block and delivery peer at specified height. Returns errMissingBlock if a block was not found

func (*BlockPool) Cleanup Uses

func (pool *BlockPool) Cleanup()

Cleanup performs pool and peer cleanup

func (*BlockPool) FirstTwoBlocksAndPeers Uses

func (pool *BlockPool) FirstTwoBlocksAndPeers() (first, second *BlockData, err error)

FirstTwoBlocksAndPeers returns the blocks and the delivery peers at pool's height H and H+1.

func (*BlockPool) InvalidateFirstTwoBlocks Uses

func (pool *BlockPool) InvalidateFirstTwoBlocks(err error)

InvalidateFirstTwoBlocks removes the peers that sent us the first two blocks, blocks are removed by RemovePeer().

func (*BlockPool) MakeNextRequests Uses

func (pool *BlockPool) MakeNextRequests(maxNumRequests int)

MakeNextRequests creates more requests if the block pool is running low.

func (*BlockPool) NeedsBlocks Uses

func (pool *BlockPool) NeedsBlocks() bool

NeedsBlocks returns true if more blocks are required.

func (*BlockPool) NumPeers Uses

func (pool *BlockPool) NumPeers() int

NumPeers returns the number of peers in the pool

func (*BlockPool) ProcessedCurrentHeightBlock Uses

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 Uses

func (pool *BlockPool) ReachedMaxHeight() bool

ReachedMaxHeight check if the pool has reached the maximum peer height.

func (*BlockPool) RemovePeer Uses

func (pool *BlockPool) RemovePeer(peerID p2p.ID, err error)

RemovePeer removes the blocks and requests from the peer, reschedules them and deletes the peer.

func (*BlockPool) RemovePeerAtCurrentHeights Uses

func (pool *BlockPool) RemovePeerAtCurrentHeights(err error)

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.

func (*BlockPool) SetLogger Uses

func (pool *BlockPool) SetLogger(l log.Logger)

SetLogger sets the logger of the pool.

func (*BlockPool) UpdatePeer Uses

func (pool *BlockPool) UpdatePeer(peerID p2p.ID, height int64) error

UpdatePeer adds a new peer or updates an existing peer with a new height. If a peer is short it is not added.

type BlockchainMessage Uses

type BlockchainMessage interface {
    ValidateBasic() error

BlockchainMessage is a generic message for this reactor.

type BlockchainReactor Uses

type BlockchainReactor struct {
    // contains filtered or unexported fields

BlockchainReactor handles long-term catchup syncing.

func NewBlockchainReactor Uses

func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore,
    fastSync bool) *BlockchainReactor

NewBlockchainReactor returns new reactor instance.

func (*BlockchainReactor) AddPeer Uses

func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)

AddPeer implements Reactor by sending our state to peer.

func (*BlockchainReactor) GetChannels Uses

func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor

func (*BlockchainReactor) OnStart Uses

func (bcR *BlockchainReactor) OnStart() error

OnStart implements service.Service.

func (*BlockchainReactor) OnStop Uses

func (bcR *BlockchainReactor) OnStop()

OnStop implements service.Service.

func (*BlockchainReactor) Receive Uses

func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)

Receive implements Reactor by handling 4 types of messages (look below).

func (*BlockchainReactor) RemovePeer Uses

func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})

RemovePeer implements Reactor by removing peer from the pool.

func (*BlockchainReactor) SetLogger Uses

func (bcR *BlockchainReactor) SetLogger(l log.Logger)

SetLogger implements service.Service by setting the logger on reactor and pool.

type BpPeer Uses

type BpPeer struct {
    ID  p2p.ID

    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 Uses

func NewBpPeer(
    peerID p2p.ID, height int64, onErr func(err error, peerID p2p.ID), params *BpPeerParams) *BpPeer

NewBpPeer creates a new peer.

func (*BpPeer) AddBlock Uses

func (peer *BpPeer) AddBlock(block *types.Block, recvSize int) error

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 Uses

func (peer *BpPeer) BlockAtHeight(height int64) (*types.Block, error)

BlockAtHeight returns the block at a given height if available and errMissingBlock otherwise.

func (*BpPeer) CheckRate Uses

func (peer *BpPeer) CheckRate() error

CheckRate verifies that the response rate of the peer is acceptable (higher than the minimum allowed).

func (*BpPeer) Cleanup Uses

func (peer *BpPeer) Cleanup()

Cleanup performs cleanup of the peer, removes blocks, requests, stops timer and monitor.

func (*BpPeer) RemoveBlock Uses

func (peer *BpPeer) RemoveBlock(height int64)

RemoveBlock removes the block of given height

func (*BpPeer) RequestSent Uses

func (peer *BpPeer) RequestSent(height int64)

RequestSent records that a request was sent, and starts the peer timer and monitor if needed.

func (*BpPeer) SetLogger Uses

func (peer *BpPeer) SetLogger(l log.Logger)

SetLogger sets the logger of the peer.

func (*BpPeer) String Uses

func (peer *BpPeer) String() string

String returns a string representation of a peer.

type BpPeerParams Uses

type BpPeerParams struct {
    // contains filtered or unexported fields

BpPeerParams stores the peer parameters that are used when creating a peer.

func BpPeerDefaultParams Uses

func BpPeerDefaultParams() *BpPeerParams

BpPeerDefaultParams returns the default peer parameters.

Package v1 imports 15 packages (graph) and is imported by 1 packages. Updated 2020-02-22. Refresh now. Tools for package owners.