Documentation
¶
Index ¶
- Variables
- func BlockMatchDraftQC(b *block.DraftBlock, escortQC *block.QuorumCert) bool
- type Block
- type BlockReader
- type Chain
- func (c *Chain) AddBlock(newBlock *block.Block, escortQC *block.QuorumCert) (*Fork, error)
- func (c *Chain) AddDraft(b *block.DraftBlock)
- func (c *Chain) BestBlock() *block.Block
- func (c *Chain) BestKBlock() (*block.Block, error)
- func (c *Chain) BestQC() *block.QuorumCert
- func (c *Chain) BuildLastCommitInfo(parent *block.Block, blk *block.Block) abci.CommitInfo
- func (c *Chain) DraftLen() int
- func (c *Chain) FindEpochOnBlock(num uint32) (uint64, error)
- func (c *Chain) GenesisBlock() *block.Block
- func (c *Chain) GetAncestorBlockID(descendantID types.Bytes32, ancestorNum uint32) (types.Bytes32, error)
- func (c *Chain) GetBestNextValidatorSet() *cmttypes.ValidatorSet
- func (c *Chain) GetBestValidatorSet() *cmttypes.ValidatorSet
- func (c *Chain) GetBlock(id types.Bytes32) (*block.Block, error)
- func (c *Chain) GetBlockBody(id types.Bytes32) (*block.Body, error)
- func (c *Chain) GetBlockHeader(id types.Bytes32) (*block.Header, error)
- func (c *Chain) GetBlockRaw(id types.Bytes32) (block.Raw, error)
- func (c *Chain) GetDraft(blkID types.Bytes32) *block.DraftBlock
- func (c *Chain) GetDraftByEscortQC(qc *block.QuorumCert) *block.DraftBlock
- func (c *Chain) GetDraftByNum(num uint32) *block.DraftBlock
- func (c *Chain) GetDraftByParentID(parentID types.Bytes32) *block.DraftBlock
- func (c *Chain) GetDraftsUpTo(commitedBlkID types.Bytes32, qcHigh *block.QuorumCert) []*block.DraftBlock
- func (c *Chain) GetFinalizeBlockResponse(blockID types.Bytes32) (*v1.FinalizeBlockResponse, error)
- func (c *Chain) GetInitChainResponse() (*v1.InitChainResponse, error)
- func (c *Chain) GetNextValidatorSet(num uint32) *cmttypes.ValidatorSet
- func (c *Chain) GetQCForBlock(blkID types.Bytes32) (*block.QuorumCert, error)
- func (c *Chain) GetTransaction(blockID types.Bytes32, index uint64) (cmttypes.Tx, error)
- func (c *Chain) GetTransactionMeta(txID []byte, headBlockID types.Bytes32) (*TxMeta, error)
- func (c *Chain) GetTrunkBlock(num uint32) (*block.Block, error)
- func (c *Chain) GetTrunkBlockHeader(num uint32) (*block.Header, error)
- func (c *Chain) GetTrunkBlockID(num uint32) (types.Bytes32, error)
- func (c *Chain) GetTrunkBlockRaw(num uint32) (block.Raw, error)
- func (c *Chain) GetTrunkTransaction(txID []byte) (cmttypes.Tx, *TxMeta, error)
- func (c *Chain) GetTrunkTransactionMeta(txID []byte) (*TxMeta, error)
- func (c *Chain) GetValidatorSet(num uint32) *cmttypes.ValidatorSet
- func (c *Chain) GetValidatorsByHash(hash cmtbytes.HexBytes) *cmttypes.ValidatorSet
- func (c *Chain) HasDraft(blkID types.Bytes32) bool
- func (c *Chain) HasTransactionMeta(txID []byte) (bool, error)
- func (c *Chain) Initialize(gene *genesis.Genesis) error
- func (c *Chain) IsBlockExist(err error) bool
- func (c *Chain) IsBlockFinalized(id types.Bytes32) bool
- func (c *Chain) IsNotFound(err error) bool
- func (c *Chain) NewBlockReader(position types.Bytes32) BlockReader
- func (c *Chain) NewSeeker(headBlockID types.Bytes32) *Seeker
- func (c *Chain) NewTicker() co.Waiter
- func (c *Chain) PruneDraftsUpTo(lastCommitted *block.DraftBlock)
- func (c *Chain) RawBlocksCacheLen() int
- func (c *Chain) SaveFinalizeBlockResponse(blockID types.Bytes32, res *v1.FinalizeBlockResponse) error
- func (c *Chain) SaveInitChainResponse(res *v1.InitChainResponse) error
- func (c *Chain) SaveValidatorSet(vset *cmttypes.ValidatorSet)
- type Fork
- type ProposalMap
- func (p *ProposalMap) Add(blk *block.DraftBlock)
- func (p *ProposalMap) CleanAll()
- func (p *ProposalMap) Get(blkID types.Bytes32) *block.DraftBlock
- func (p *ProposalMap) GetDraftsByNum(num uint32) []*block.DraftBlock
- func (p *ProposalMap) GetDraftsByParentID(parentID types.Bytes32) []*block.DraftBlock
- func (p *ProposalMap) GetOneByEscortQC(qc *block.QuorumCert) *block.DraftBlock
- func (p *ProposalMap) GetProposalsUpTo(committedBlkID types.Bytes32, qcHigh *block.QuorumCert) []*block.DraftBlock
- func (p *ProposalMap) Has(blkID types.Bytes32) bool
- func (p *ProposalMap) Len() int
- func (p *ProposalMap) PruneUpTo(lastCommitted *block.DraftBlock)
- type Seeker
- type TxMeta
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrBlockExist = errors.New("block already exists") ErrQCMismatch = errors.New("QC mismatch") ErrEmptyDraft = errors.New("empty draft") )
var ErrInvalidGenesis = errors.New("invalid genesis")
Functions ¶
func BlockMatchDraftQC ¶
func BlockMatchDraftQC(b *block.DraftBlock, escortQC *block.QuorumCert) bool
qc is for that block? blk is derived from DraftBlock message. pass it in if already decoded
Types ¶
type BlockReader ¶
BlockReader defines the interface to read Block
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain describes a persistent block chain. It's thread-safe.
func (*Chain) AddBlock ¶
AddBlock add a new block into block chain. Once reorg happened (len(Trunk) > 0 && len(Branch) >0), Fork.Branch will be the chain transitted from trunk to branch. Reorg happens when isTrunk is true.
func (*Chain) AddDraft ¶
func (c *Chain) AddDraft(b *block.DraftBlock)
func (*Chain) BestQC ¶
func (c *Chain) BestQC() *block.QuorumCert
func (*Chain) BuildLastCommitInfo ¶
BuildLastCommitInfo builds a CommitInfo from the given block and validator set. If you want to load the validator set from the store instead of providing it, use buildLastCommitInfoFromStore.
func (*Chain) GenesisBlock ¶
GenesisBlock returns genesis block.
func (*Chain) GetAncestorBlockID ¶
func (c *Chain) GetAncestorBlockID(descendantID types.Bytes32, ancestorNum uint32) (types.Bytes32, error)
GetAncestorBlockID get ancestor block ID of descendant for given ancestor block.
func (*Chain) GetBestNextValidatorSet ¶
func (c *Chain) GetBestNextValidatorSet() *cmttypes.ValidatorSet
func (*Chain) GetBestValidatorSet ¶
func (c *Chain) GetBestValidatorSet() *cmttypes.ValidatorSet
func (*Chain) GetBlockBody ¶
GetBlockBody get block body by block id.
func (*Chain) GetBlockHeader ¶
GetBlockHeader get block header by block id.
func (*Chain) GetBlockRaw ¶
GetBlockRaw get block rlp encoded bytes for given id. Never modify the returned raw block.
func (*Chain) GetDraftByEscortQC ¶
func (c *Chain) GetDraftByEscortQC(qc *block.QuorumCert) *block.DraftBlock
func (*Chain) GetDraftByNum ¶
func (c *Chain) GetDraftByNum(num uint32) *block.DraftBlock
func (*Chain) GetDraftByParentID ¶
func (c *Chain) GetDraftByParentID(parentID types.Bytes32) *block.DraftBlock
func (*Chain) GetDraftsUpTo ¶
func (c *Chain) GetDraftsUpTo(commitedBlkID types.Bytes32, qcHigh *block.QuorumCert) []*block.DraftBlock
func (*Chain) GetFinalizeBlockResponse ¶ added in v0.0.4
func (*Chain) GetInitChainResponse ¶ added in v0.0.4
func (c *Chain) GetInitChainResponse() (*v1.InitChainResponse, error)
func (*Chain) GetNextValidatorSet ¶
func (c *Chain) GetNextValidatorSet(num uint32) *cmttypes.ValidatorSet
func (*Chain) GetQCForBlock ¶
func (*Chain) GetTransaction ¶
GetTransaction get transaction for given block and index.
func (*Chain) GetTransactionMeta ¶
GetTransactionMeta get transaction meta info, on the chain defined by head block ID.
func (*Chain) GetTrunkBlock ¶
GetTrunkBlock get block on trunk by given block number.
func (*Chain) GetTrunkBlockHeader ¶
GetTrunkBlockHeader get block header on trunk by given block number.
func (*Chain) GetTrunkBlockID ¶
GetTrunkBlockID get block id on trunk by given block number.
func (*Chain) GetTrunkBlockRaw ¶
GetTrunkBlockRaw get block raw on trunk by given block number.
func (*Chain) GetTrunkTransaction ¶
GetTrunkTransaction get transaction on trunk by given tx id.
func (*Chain) GetTrunkTransactionMeta ¶
GetTrunkTransactionMeta get transaction meta info on trunk by given tx id.
func (*Chain) GetValidatorSet ¶
func (c *Chain) GetValidatorSet(num uint32) *cmttypes.ValidatorSet
func (*Chain) GetValidatorsByHash ¶
func (c *Chain) GetValidatorsByHash(hash cmtbytes.HexBytes) *cmttypes.ValidatorSet
FIXME: should add cache
func (*Chain) HasTransactionMeta ¶
GetTransactionMeta get transaction meta info, on the chain defined by head block ID.
func (*Chain) IsBlockExist ¶
IsBlockExist returns if the error means block was already in the chain.
func (*Chain) IsNotFound ¶
IsNotFound returns if an error means not found.
func (*Chain) NewBlockReader ¶
func (c *Chain) NewBlockReader(position types.Bytes32) BlockReader
NewBlockReader generate an object that implements the BlockReader interface
func (*Chain) PruneDraftsUpTo ¶
func (c *Chain) PruneDraftsUpTo(lastCommitted *block.DraftBlock)
func (*Chain) RawBlocksCacheLen ¶
func (*Chain) SaveFinalizeBlockResponse ¶ added in v0.0.4
func (*Chain) SaveInitChainResponse ¶ added in v0.0.4
func (c *Chain) SaveInitChainResponse(res *v1.InitChainResponse) error
func (*Chain) SaveValidatorSet ¶
func (c *Chain) SaveValidatorSet(vset *cmttypes.ValidatorSet)
type ProposalMap ¶
type ProposalMap struct {
// contains filtered or unexported fields
}
func NewProposalMap ¶
func NewProposalMap(c *Chain) *ProposalMap
func (*ProposalMap) Add ¶
func (p *ProposalMap) Add(blk *block.DraftBlock)
func (*ProposalMap) CleanAll ¶
func (p *ProposalMap) CleanAll()
func (*ProposalMap) Get ¶
func (p *ProposalMap) Get(blkID types.Bytes32) *block.DraftBlock
func (*ProposalMap) GetDraftsByNum ¶
func (p *ProposalMap) GetDraftsByNum(num uint32) []*block.DraftBlock
func (*ProposalMap) GetDraftsByParentID ¶
func (p *ProposalMap) GetDraftsByParentID(parentID types.Bytes32) []*block.DraftBlock
func (*ProposalMap) GetOneByEscortQC ¶
func (p *ProposalMap) GetOneByEscortQC(qc *block.QuorumCert) *block.DraftBlock
func (*ProposalMap) GetProposalsUpTo ¶
func (p *ProposalMap) GetProposalsUpTo(committedBlkID types.Bytes32, qcHigh *block.QuorumCert) []*block.DraftBlock
func (*ProposalMap) Len ¶
func (p *ProposalMap) Len() int
func (*ProposalMap) PruneUpTo ¶
func (p *ProposalMap) PruneUpTo(lastCommitted *block.DraftBlock)