Documentation ¶
Index ¶
- Constants
- Variables
- func BlockStoreDB(config *cfg.Viper) (dbm.DB, dbm.DB)
- func LoadBlockStore(blockStoreDB, blockArchiveDB dbm.DB, height def.INT) (*pbtypes.Block, *pbtypes.BlockMeta, *pbtypes.BlockID)
- type BlockExecuterFunc
- type BlockPool
- func (pool *BlockPool) AddBlock(peerID string, block *pbtypes.Block, blockSize int)
- func (pool *BlockPool) GetStatus() (height def.INT, numPending int32, lenRequesters int)
- func (pool *BlockPool) IsCaughtUp() bool
- func (pool *BlockPool) OnStart() error
- func (pool *BlockPool) OnStop()
- func (pool *BlockPool) PeekTwoBlocks() (first *agtypes.BlockCache, second *agtypes.BlockCache)
- func (pool *BlockPool) PopRequest()
- func (pool *BlockPool) RedoRequest(height def.INT)
- func (pool *BlockPool) RemovePeer(peerID string)
- func (pool *BlockPool) SetPeerHeight(peerID string, height def.INT)
- type BlockRequest
- type BlockStore
- func (bs *BlockStore) DeleteBlock(height def.INT) (err error)
- func (bs *BlockStore) Height() def.INT
- func (bs *BlockStore) LoadBlock(height def.INT) *agtypes.BlockCache
- func (bs *BlockStore) LoadBlockCommit(height def.INT) *agtypes.CommitCache
- func (bs *BlockStore) LoadBlockMeta(height def.INT) *pbtypes.BlockMeta
- func (bs *BlockStore) LoadBlockPart(height def.INT, index int) *pbtypes.Part
- func (bs *BlockStore) LoadSeenCommit(height def.INT) *agtypes.CommitCache
- func (bs *BlockStore) OriginHeight() def.INT
- func (bs *BlockStore) SaveBlock(block *agtypes.BlockCache, blockParts *agtypes.PartSet, ...)
- func (bs *BlockStore) SaveBlockToArchive(height def.INT, block *agtypes.BlockCache, blockParts *agtypes.PartSet, ...)
- func (bs *BlockStore) SetOriginHeight(height def.INT)
- type BlockStoreStateJSON
- type BlockVerifierFunc
- type BlockchainReactor
- func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer)
- func (bcR *BlockchainReactor) BlockArchive()
- func (bcR *BlockchainReactor) BroadcastStatusRequest() error
- func (bcR *BlockchainReactor) BroadcastStatusResponse() error
- func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
- func (bcR *BlockchainReactor) OnStart() error
- func (bcR *BlockchainReactor) OnStop()
- func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
- func (bcR *BlockchainReactor) RemovePeer(peer *p2p.Peer, reason interface{})
- func (bcR *BlockchainReactor) SetBlockExecuter(x BlockExecuterFunc)
- func (bcR *BlockchainReactor) SetBlockVerifier(v BlockVerifierFunc)
- func (bcR *BlockchainReactor) SetEventSwitch(evsw agtypes.EventSwitch)
- type NonEmptyBlockIterator
- type StoreTool
- func (st *StoreTool) BackupLastBlock(branchName string) error
- func (st *StoreTool) DelBackup(branchName string)
- func (st *StoreTool) Init(config *cfg.Viper) error
- func (st *StoreTool) LastHeight() def.INT
- func (st *StoreTool) LoadBlock(height def.INT) (*pbtypes.Block, *pbtypes.BlockMeta, *pbtypes.BlockID)
- func (st *StoreTool) RevertFromBackup(branchName string) error
- func (st *StoreTool) SaveNewLastBlock(toHeight def.INT) error
Constants ¶
const (
BlockchainChannel = byte(0x40)
)
Variables ¶
var ( ErrBlockIsNil = errors.New("the chain has no block data") ErrBranchNameUsed = errors.New("blockchain:branch name has been used") ErrConvertToFuture = errors.New("can't revert to future height") ErrRevertBackup = errors.New("revert from backup,not find data") )
var ErrNotFound = errors.New("leveldb not found")
Functions ¶
Types ¶
type BlockExecuterFunc ¶
type BlockExecuterFunc func(*agtypes.BlockCache, *agtypes.PartSet, *agtypes.CommitCache) error
type BlockPool ¶
type BlockPool struct { BaseService // contains filtered or unexported fields }
func NewBlockPool ¶
func (*BlockPool) IsCaughtUp ¶
TODO: relax conditions, prevent abuse.
func (*BlockPool) PeekTwoBlocks ¶
func (pool *BlockPool) PeekTwoBlocks() (first *agtypes.BlockCache, second *agtypes.BlockCache)
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()
Pop the first block at pool.height It must have been validated by 'second'.Commit from PeekTwoBlocks().
func (*BlockPool) RedoRequest ¶
Invalidates the block at pool.height, Remove the peer and redo request from others.
func (*BlockPool) RemovePeer ¶
type BlockRequest ¶
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
Simple low level store for blocks.
There are three types of information stored:
- BlockMeta: Meta information about each block
- Block part: Parts of each block, aggregated w/ PartSet
- Commit: The commit part of each block, for gossiping precommit votes
Currently the precommit signatures are duplicated in the Block parts as well as the Commit. In the future this may change, perhaps by moving the Commit data outside the Block.
Panics indicate probable corruption in the data
func NewBlockStore ¶
func NewBlockStore(db, archiveDB dbm.DB) *BlockStore
func (*BlockStore) DeleteBlock ¶
func (bs *BlockStore) DeleteBlock(height def.INT) (err error)
func (*BlockStore) Height ¶
func (bs *BlockStore) Height() def.INT
Height() returns the last known contiguous block height.
func (*BlockStore) LoadBlock ¶
func (bs *BlockStore) LoadBlock(height def.INT) *agtypes.BlockCache
func (*BlockStore) LoadBlockCommit ¶
func (bs *BlockStore) LoadBlockCommit(height def.INT) *agtypes.CommitCache
The +2/3 and other Precommit-votes for block at `height`. This Commit comes from block.LastCommit for `height+1`.
func (*BlockStore) LoadBlockMeta ¶
func (bs *BlockStore) LoadBlockMeta(height def.INT) *pbtypes.BlockMeta
func (*BlockStore) LoadBlockPart ¶
func (*BlockStore) LoadSeenCommit ¶
func (bs *BlockStore) LoadSeenCommit(height def.INT) *agtypes.CommitCache
NOTE: the Precommit-vote heights are for the block at `height`
func (*BlockStore) OriginHeight ¶
func (bs *BlockStore) OriginHeight() def.INT
func (*BlockStore) SaveBlock ¶
func (bs *BlockStore) SaveBlock(block *agtypes.BlockCache, blockParts *agtypes.PartSet, seenCommit *agtypes.CommitCache)
blockParts: Must be parts of the block seenCommit: The +2/3 precommits that were seen which committed at height.
If all the nodes restart after committing a block, we need this to reload the precommits to catch-up nodes to the most recent height. Otherwise they'd stall at H-1.
func (*BlockStore) SaveBlockToArchive ¶
func (bs *BlockStore) SaveBlockToArchive(height def.INT, block *agtypes.BlockCache, blockParts *agtypes.PartSet, seenCommit *agtypes.CommitCache)
func (*BlockStore) SetOriginHeight ¶
func (bs *BlockStore) SetOriginHeight(height def.INT)
type BlockStoreStateJSON ¶
func LoadBlockStoreStateJSON ¶
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON
func (BlockStoreStateJSON) Save ¶
func (bsj BlockStoreStateJSON) Save(db dbm.DB)
type BlockVerifierFunc ¶
type BlockchainReactor ¶
type BlockchainReactor struct { p2p.BaseReactor // contains filtered or unexported fields }
BlockchainReactor handles long-term catchup syncing.
func NewBlockchainReactor ¶
func (*BlockchainReactor) AddPeer ¶
func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer)
Implements Reactor
func (*BlockchainReactor) BlockArchive ¶
func (bcR *BlockchainReactor) BlockArchive()
func (*BlockchainReactor) BroadcastStatusRequest ¶
func (bcR *BlockchainReactor) BroadcastStatusRequest() error
func (*BlockchainReactor) BroadcastStatusResponse ¶
func (bcR *BlockchainReactor) BroadcastStatusResponse() error
func (*BlockchainReactor) GetChannels ¶
func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
Implements Reactor
func (*BlockchainReactor) OnStart ¶
func (bcR *BlockchainReactor) OnStart() error
func (*BlockchainReactor) OnStop ¶
func (bcR *BlockchainReactor) OnStop()
func (*BlockchainReactor) Receive ¶
func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
Implements Reactor
func (*BlockchainReactor) RemovePeer ¶
func (bcR *BlockchainReactor) RemovePeer(peer *p2p.Peer, reason interface{})
Implements Reactor
func (*BlockchainReactor) SetBlockExecuter ¶
func (bcR *BlockchainReactor) SetBlockExecuter(x BlockExecuterFunc)
func (*BlockchainReactor) SetBlockVerifier ¶
func (bcR *BlockchainReactor) SetBlockVerifier(v BlockVerifierFunc)
func (*BlockchainReactor) SetEventSwitch ¶
func (bcR *BlockchainReactor) SetEventSwitch(evsw agtypes.EventSwitch)
implements events.Eventable
type NonEmptyBlockIterator ¶
type NonEmptyBlockIterator struct {
// contains filtered or unexported fields
}
func NewNonEmptyBlockIterator ¶
func NewNonEmptyBlockIterator(store *BlockStore) *NonEmptyBlockIterator
func (*NonEmptyBlockIterator) HasMore ¶
func (i *NonEmptyBlockIterator) HasMore() bool
func (*NonEmptyBlockIterator) Next ¶
func (i *NonEmptyBlockIterator) Next() *agtypes.BlockCache
type StoreTool ¶
type StoreTool struct {
// contains filtered or unexported fields
}