Documentation ¶
Index ¶
- Variables
- type BlockStoreState
- type Chain
- func (c *Chain) BestBlockHash() *bc.Hash
- func (c *Chain) BestBlockHeader() *types.BlockHeader
- func (c *Chain) BestBlockHeight() uint64
- func (c *Chain) BlockExist(hash *bc.Hash) bool
- func (c *Chain) BlockWaiter(height uint64) <-chan struct{}
- func (c *Chain) CalcNextBits(preBlock *bc.Hash) (uint64, error)
- func (c *Chain) CalcNextSeed(preBlock *bc.Hash) (*bc.Hash, error)
- func (c *Chain) GetBlockByHash(hash *bc.Hash) (*types.Block, error)
- func (c *Chain) GetBlockByHeight(height uint64) (*types.Block, error)
- func (c *Chain) GetHeaderByHash(hash *bc.Hash) (*types.BlockHeader, error)
- func (c *Chain) GetHeaderByHeight(height uint64) (*types.BlockHeader, error)
- func (c *Chain) GetTransactionStatus(hash *bc.Hash) (*bc.TransactionStatus, error)
- func (c *Chain) InMainChain(hash bc.Hash) bool
- func (c *Chain) ProcessBlock(block *types.Block, txStatus *bc.TransactionStatus) (bool, error)
- type OrphanManage
- func (o *OrphanManage) Add(block *types.Block, txStatus *bc.TransactionStatus)
- func (o *OrphanManage) BlockExist(hash *bc.Hash) bool
- func (o *OrphanManage) Delete(hash *bc.Hash)
- func (o *OrphanManage) Get(hash *bc.Hash) (*types.Block, *bc.TransactionStatus, bool)
- func (o *OrphanManage) GetPrevOrphans(hash *bc.Hash) ([]*bc.Hash, bool)
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadBlock is returned when a block is invalid. ErrBadBlock = errors.New("invalid block") // ErrBadStateRoot is returned when the computed assets merkle root // disagrees with the one declared in a block header. ErrBadStateRoot = errors.New("invalid state merkle root") )
var ErrBadTx = errors.New("invalid transaction")
ErrBadTx is returned for transactions failing validation
var ErrTheDistantFuture = errors.New("block height too far in future")
ErrTheDistantFuture is returned when waiting for a blockheight too far in excess of the tip of the blockchain.
Functions ¶
This section is empty.
Types ¶
type BlockStoreState ¶
BlockStoreState represents the core's db status
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain provides functions for working with the Bytom block chain.
func (*Chain) BestBlockHash ¶
BestBlockHash return the hash of the chain tail block
func (*Chain) BestBlockHeader ¶
func (c *Chain) BestBlockHeader() *types.BlockHeader
BestBlockHeader returns the chain tail block
func (*Chain) BestBlockHeight ¶
BestBlockHeight returns the current height of the blockchain.
func (*Chain) BlockExist ¶
BlockExist check is a block in chain or orphan
func (*Chain) BlockWaiter ¶
BlockWaiter returns a channel that waits for the block at the given height.
func (*Chain) CalcNextBits ¶
CalcNextBits return the seed for the given block
func (*Chain) CalcNextSeed ¶
CalcNextSeed return the seed for the given block
func (*Chain) GetBlockByHash ¶
GetBlockByHash return a block by given hash
func (*Chain) GetBlockByHeight ¶
GetBlockByHeight return a block header by given height
func (*Chain) GetHeaderByHash ¶
GetHeaderByHash return a block header by given hash
func (*Chain) GetHeaderByHeight ¶
func (c *Chain) GetHeaderByHeight(height uint64) (*types.BlockHeader, error)
GetHeaderByHeight return a block header by given height
func (*Chain) GetTransactionStatus ¶
GetTransactionStatus return the transaction status of give block
func (*Chain) InMainChain ¶
InMainChain checks wheather a block is in the main chain
func (*Chain) ProcessBlock ¶
ProcessBlock is the entry for chain update
type OrphanManage ¶
type OrphanManage struct {
// contains filtered or unexported fields
}
OrphanManage is use to handle all the orphan block
func NewOrphanManage ¶
func NewOrphanManage() *OrphanManage
NewOrphanManage return a new orphan block
func (*OrphanManage) Add ¶
func (o *OrphanManage) Add(block *types.Block, txStatus *bc.TransactionStatus)
Add will add the block to OrphanManage
func (*OrphanManage) BlockExist ¶
func (o *OrphanManage) BlockExist(hash *bc.Hash) bool
BlockExist check is the block in OrphanManage
func (*OrphanManage) Delete ¶
func (o *OrphanManage) Delete(hash *bc.Hash)
Delete will delete the block from OrphanManage
func (*OrphanManage) Get ¶
func (o *OrphanManage) Get(hash *bc.Hash) (*types.Block, *bc.TransactionStatus, bool)
Get return the orphan block by hash
func (*OrphanManage) GetPrevOrphans ¶
GetPrevOrphans return the list of child orphans
type Store ¶
type Store interface { BlockExist(*bc.Hash) bool GetBlock(*bc.Hash) (*types.Block, error) GetStoreStatus() *BlockStoreState GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error) LoadBlockIndex() (*state.BlockIndex, error) SaveBlock(*types.Block, *bc.TransactionStatus) error SaveChainStatus(*state.BlockNode) error }
Store provides storage interface for blockchain data