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

package v0

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

Index

Package Files

codec.go pool.go reactor.go

Constants

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 BlockPool Uses

type BlockPool struct {
    cmn.BaseService
    // contains filtered or unexported fields
}

BlockPool keeps track of the fast sync peers, block requests and block responses.

func NewBlockPool Uses

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 Uses

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

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 Uses

func (pool *BlockPool) GetStatus() (height int64, numPending int32, lenRequesters int)

GetStatus returns pool's height, numPending requests and the number of requesters.

func (*BlockPool) IsCaughtUp Uses

func (pool *BlockPool) IsCaughtUp() bool

IsCaughtUp returns true if this node is caught up, false - otherwise. TODO: relax conditions, prevent abuse.

func (*BlockPool) MaxPeerHeight Uses

func (pool *BlockPool) MaxPeerHeight() int64

MaxPeerHeight returns the highest reported height.

func (*BlockPool) OnStart Uses

func (pool *BlockPool) OnStart() error

OnStart implements cmn.Service by spawning requesters routine and recording pool's start time.

func (*BlockPool) PeekTwoBlocks Uses

func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)

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 Uses

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 Uses

func (pool *BlockPool) RedoRequest(height int64) p2p.ID

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 Uses

func (pool *BlockPool) RemovePeer(peerID p2p.ID)

RemovePeer removes the peer with peerID from the pool. If there's no peer with peerID, function is a no-op.

func (*BlockPool) SetPeerHeight Uses

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

SetPeerHeight sets the peer's alleged blockchain height.

type BlockRequest Uses

type BlockRequest struct {
    Height int64
    PeerID p2p.ID
}

BlockRequest stores a block request identified by the block Height and the PeerID responsible for delivering the block

type BlockchainMessage Uses

type BlockchainMessage interface {
    ValidateBasic() error
}

BlockchainMessage is a generic message for this reactor.

type BlockchainReactor Uses

type BlockchainReactor struct {
    p2p.BaseReactor
    // 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) BroadcastStatusRequest Uses

func (bcR *BlockchainReactor) BroadcastStatusRequest() error

BroadcastStatusRequest broadcasts `BlockStore` height.

func (*BlockchainReactor) GetChannels Uses

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

GetChannels implements Reactor

func (*BlockchainReactor) OnStart Uses

func (bcR *BlockchainReactor) OnStart() error

OnStart implements cmn.Service.

func (*BlockchainReactor) OnStop Uses

func (bcR *BlockchainReactor) OnStop()

OnStop implements cmn.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 cmn.Service by setting the logger on reactor and pool.

Package v0 imports 15 packages (graph) and is imported by 1 packages. Updated 2019-09-16. Refresh now. Tools for package owners.