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) 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 OrphanManage
- type Store
- type TxDesc
- type TxPool
- func (tp *TxPool) AddErrCache(txHash *bc.Hash, err error)
- func (tp *TxPool) AddTransaction(tx *types.Tx, gasOnlyTx bool, height, fee uint64) (*TxDesc, error)
- func (tp *TxPool) Count() int
- func (tp *TxPool) GetErrCache(txHash *bc.Hash) error
- func (tp *TxPool) GetNewTxCh() chan *types.Tx
- func (tp *TxPool) GetTransaction(txHash *bc.Hash) (*TxDesc, error)
- func (tp *TxPool) GetTransactionUTXO(tx *bc.Tx) *state.UtxoViewpoint
- func (tp *TxPool) GetTransactions() []*TxDesc
- func (tp *TxPool) HaveTransaction(txHash *bc.Hash) bool
- func (tp *TxPool) IsTransactionInErrCache(txHash *bc.Hash) bool
- func (tp *TxPool) IsTransactionInPool(txHash *bc.Hash) bool
- func (tp *TxPool) RemoveTransaction(txHash *bc.Hash)
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 ( // ErrTransactionNotExist is the pre-defined error message ErrTransactionNotExist = errors.New("transaction are not existed in the mempool") // ErrPoolIsFull indicates the pool is full ErrPoolIsFull = errors.New("transaction pool reach the max number") )
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 ¶ added in v0.4.6
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 ¶ added in v0.1.4
BestBlockHash return the hash of the chain tail block
func (*Chain) BestBlockHeader ¶ added in v0.4.3
func (c *Chain) BestBlockHeader() *types.BlockHeader
BestBlockHeader returns the chain tail block
func (*Chain) BestBlockHeight ¶ added in v0.4.6
BestBlockHeight returns the current height of the blockchain.
func (*Chain) BlockExist ¶ added in v0.1.4
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 ¶ added in v0.4.3
CalcNextBits return the seed for the given block
func (*Chain) CalcNextSeed ¶ added in v0.4.3
CalcNextSeed return the seed for the given block
func (*Chain) GetBlockByHash ¶ added in v0.1.4
GetBlockByHash return a block by given hash
func (*Chain) GetBlockByHeight ¶ added in v0.1.4
GetBlockByHeight return a block by given height
func (*Chain) GetTransactionStatus ¶ added in v0.4.1
GetTransactionStatus return the transaction status of give block
func (*Chain) GetTransactionsUtxo ¶ added in v0.3.0
GetTransactionsUtxo return all the utxos that related to the txs' inputs
func (*Chain) InMainChain ¶ added in v0.2.0
InMainChain checks wheather a block is in the main chain
func (*Chain) ProcessBlock ¶ added in v0.1.4
ProcessBlock is the entry for chain update
type OrphanManage ¶ added in v0.1.4
type OrphanManage struct {
// contains filtered or unexported fields
}
OrphanManage is use to handle all the orphan block
func NewOrphanManage ¶ added in v0.1.4
func NewOrphanManage() *OrphanManage
NewOrphanManage return a new orphan block
func (*OrphanManage) Add ¶ added in v0.1.4
func (o *OrphanManage) Add(block *types.Block)
Add will add the block to OrphanManage
func (*OrphanManage) BlockExist ¶ added in v0.1.4
func (o *OrphanManage) BlockExist(hash *bc.Hash) bool
BlockExist check is the block in OrphanManage
func (*OrphanManage) Delete ¶ added in v0.1.4
func (o *OrphanManage) Delete(hash *bc.Hash)
Delete will delete the block from OrphanManage
func (*OrphanManage) GetPrevOrphans ¶ added in v0.4.6
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) GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error GetUtxo(*bc.Hash) (*storage.UtxoEntry, error) LoadBlockIndex() (*state.BlockIndex, error) SaveBlock(*types.Block, *bc.TransactionStatus) error SaveChainStatus(*state.BlockNode, *state.UtxoViewpoint) error }
Store provides storage interface for blockchain data
type TxDesc ¶
type TxDesc struct { Tx *types.Tx Added time.Time Height uint64 Weight uint64 Fee uint64 FeePerKB uint64 }
TxDesc store tx and related info for mining strategy
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool is use for store the unconfirmed transaction
func (*TxPool) AddErrCache ¶
AddErrCache add a failed transaction record to lru cache
func (*TxPool) AddTransaction ¶
AddTransaction add a verified transaction to pool
func (*TxPool) GetErrCache ¶
GetErrCache return the error of the transaction
func (*TxPool) GetNewTxCh ¶
GetNewTxCh return a unconfirmed transaction feed channel
func (*TxPool) GetTransaction ¶
GetTransaction return the TxDesc by hash
func (*TxPool) GetTransactionUTXO ¶ added in v0.4.0
func (tp *TxPool) GetTransactionUTXO(tx *bc.Tx) *state.UtxoViewpoint
GetTransactionUTXO return unconfirmed utxo
func (*TxPool) GetTransactions ¶
GetTransactions return all the transactions in the pool
func (*TxPool) HaveTransaction ¶
HaveTransaction IsTransactionInErrCache check is transaction in errCache or pool
func (*TxPool) IsTransactionInErrCache ¶
IsTransactionInErrCache check wheather a transaction in errCache or not
func (*TxPool) IsTransactionInPool ¶
IsTransactionInPool check wheather a transaction in pool or not
func (*TxPool) RemoveTransaction ¶
RemoveTransaction remove a transaction from the pool