Versions in this module Expand all Collapse all v1 v1.1.2 Sep 16, 2021 Changes in this version + const MsgNewTx + const MsgRemoveTx + var ErrBadBlock = errors.New("invalid block") + var ErrBadStateRoot = errors.New("invalid state merkle root") + var ErrBadTx = errors.New("invalid transaction") + var ErrBannedInputScript = errors.New("input script have been banned") + var ErrDustTx = errors.New("transaction is dust tx") + var ErrPoolIsFull = errors.New("transaction pool reach the max number") + var ErrTransactionNotExist = errors.New("transaction are not existed in the mempool") + type BlockStoreState struct + Hash *bc.Hash + Height uint64 + type Chain struct + func NewChain(store Store, txPool *TxPool) (*Chain, error) + func NewChainWithOrphanManage(store Store, txPool *TxPool, manage *OrphanManage) (*Chain, error) + 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) GetBlockIndex() *state.BlockIndex + 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) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) error + func (c *Chain) GetTxPool() *TxPool + func (c *Chain) InMainChain(hash bc.Hash) bool + func (c *Chain) ProcessBlock(block *types.Block) (bool, error) + func (c *Chain) ValidateTx(tx *types.Tx) (bool, error) + type OrphanBlock struct + func NewOrphanBlock(block *types.Block, expiration time.Time) *OrphanBlock + func (o *OrphanBlock) Equals(o1 *OrphanBlock) bool + type OrphanManage struct + func NewOrphanManage() *OrphanManage + func NewOrphanManageWithData(orphan map[bc.Hash]*OrphanBlock, prevOrphans map[bc.Hash][]*bc.Hash) *OrphanManage + func (o *OrphanManage) Add(block *types.Block) + func (o *OrphanManage) BlockExist(hash *bc.Hash) bool + func (o *OrphanManage) Delete(hash *bc.Hash) + func (o *OrphanManage) Equals(o1 *OrphanManage) bool + func (o *OrphanManage) Get(hash *bc.Hash) (*types.Block, bool) + func (o *OrphanManage) GetPrevOrphans(hash *bc.Hash) ([]*bc.Hash, bool) + type Store interface + BlockExist func(*bc.Hash) bool + GetBlock func(*bc.Hash) (*types.Block, error) + GetStoreStatus func() *BlockStoreState + GetTransactionStatus func(*bc.Hash) (*bc.TransactionStatus, error) + GetTransactionsUtxo func(*state.UtxoViewpoint, []*bc.Tx) error + GetUtxo func(*bc.Hash) (*storage.UtxoEntry, error) + LoadBlockIndex func(uint64) (*state.BlockIndex, error) + SaveBlock func(*types.Block, *bc.TransactionStatus) error + SaveChainStatus func(*state.BlockNode, *state.UtxoViewpoint) error + type TxDesc struct + Added time.Time + Fee uint64 + Height uint64 + StatusFail bool + Tx *types.Tx + Weight uint64 + type TxMsgEvent struct + TxMsg *TxPoolMsg + type TxPool struct + func NewTxPool(store Store, dispatcher *event.Dispatcher) *TxPool + func (tp *TxPool) AddErrCache(txHash *bc.Hash, err error) + func (tp *TxPool) ExpireOrphan(now time.Time) + func (tp *TxPool) GetErrCache(txHash *bc.Hash) error + func (tp *TxPool) GetTransaction(txHash *bc.Hash) (*TxDesc, error) + func (tp *TxPool) GetTransactions() []*TxDesc + func (tp *TxPool) HaveTransaction(txHash *bc.Hash) bool + func (tp *TxPool) IsDust(tx *types.Tx) bool + func (tp *TxPool) IsTransactionInErrCache(txHash *bc.Hash) bool + func (tp *TxPool) IsTransactionInPool(txHash *bc.Hash) bool + func (tp *TxPool) ProcessTransaction(tx *types.Tx, statusFail bool, height, fee uint64) (bool, error) + func (tp *TxPool) RemoveTransaction(txHash *bc.Hash) + type TxPoolMsg struct + MsgType int