Documentation ¶
Index ¶
- Constants
- Variables
- type Chain
- func (c *Chain) AllValidators(blockHash *bc.Hash) ([]*state.Validator, error)
- func (c *Chain) BestBlockHash() *bc.Hash
- func (c *Chain) BestBlockHeader() *types.BlockHeader
- func (c *Chain) BestBlockHeight() uint64
- func (c *Chain) BestChain() (uint64, bc.Hash)
- func (c *Chain) BlockExist(hash *bc.Hash) bool
- func (c *Chain) BlockWaiter(height uint64) <-chan struct{}
- func (c *Chain) FinalizedHeight() uint64
- 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) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) error
- func (c *Chain) GetTxPool() *TxPool
- func (c *Chain) GetValidator(prevHash *bc.Hash, timeStamp uint64) (*state.Validator, error)
- func (c *Chain) InMainChain(hash bc.Hash) bool
- func (c *Chain) LastFinalizedHeader() (*types.BlockHeader, error)
- func (c *Chain) LastJustifiedHeader() (*types.BlockHeader, error)
- func (c *Chain) PrevCheckpointByPrevHash(preBlockHash *bc.Hash) (*state.Checkpoint, error)
- func (c *Chain) ProcessBlock(block *types.Block) (bool, error)
- func (c *Chain) ProcessBlockVerification(v *casper.ValidCasperSignMsg) error
- func (c *Chain) ProgramConverter(prog []byte) ([]byte, error)
- func (c *Chain) SignBlockHeader(blockHeader *types.BlockHeader)
- func (c *Chain) ValidateTx(tx *types.Tx) (bool, error)
- type OrphanBlock
- type 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 TxDesc
- type TxMsgEvent
- type 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, height, fee uint64) (bool, error)
- func (tp *TxPool) RemoveTransaction(txHash *bc.Hash)
- type TxPoolMsg
Constants ¶
const ( MsgNewTx = iota MsgRemoveTx )
msg type
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") // ErrDustTx indicates transaction is dust tx ErrDustTx = errors.New("transaction is dust tx") )
var ErrBadTx = errors.New("invalid transaction")
ErrBadTx is returned for transactions failing validation
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain provides functions for working with the Bytom block chain.
func NewChainWithOrphanManage ¶ added in v1.0.10
func NewChainWithOrphanManage(store state.Store, txPool *TxPool, manage *OrphanManage, eventDispatcher *event.Dispatcher) (*Chain, error)
func (*Chain) AllValidators ¶ added in v1.2.1
AllValidators return all validators has vote num
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) BestChain ¶ added in v1.2.1
BestChain return the current height and block hash of the chain
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) FinalizedHeight ¶ added in v1.2.1
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 header by given height
func (*Chain) GetHeaderByHash ¶ added in v1.0.4
GetHeaderByHash return a block header by given hash
func (*Chain) GetHeaderByHeight ¶ added in v1.0.4
func (c *Chain) GetHeaderByHeight(height uint64) (*types.BlockHeader, error)
GetHeaderByHeight return a block header by given height
func (*Chain) GetTransactionsUtxo ¶ added in v0.3.0
GetTransactionsUtxo return all the utxos that related to the txs' inputs
func (*Chain) GetValidator ¶ added in v1.2.1
GetValidator return validator by specified blockHash and timestamp
func (*Chain) InMainChain ¶ added in v0.2.0
InMainChain checks wheather a block is in the main chain
func (*Chain) LastFinalizedHeader ¶ added in v1.2.1
func (c *Chain) LastFinalizedHeader() (*types.BlockHeader, error)
LastFinalizedHeader return the last finalized block header of the block chain
func (*Chain) LastJustifiedHeader ¶ added in v1.2.1
func (c *Chain) LastJustifiedHeader() (*types.BlockHeader, error)
LastJustifiedHeader return the last justified block header of the block chain
func (*Chain) PrevCheckpointByPrevHash ¶ added in v1.2.1
PrevCheckpointByPrevHash get previous checkpoint by previous block hash
func (*Chain) ProcessBlock ¶ added in v0.1.4
ProcessBlock is the entry for chain update
func (*Chain) ProcessBlockVerification ¶ added in v1.2.1
func (c *Chain) ProcessBlockVerification(v *casper.ValidCasperSignMsg) error
ProcessBlockVerification process block verification
func (*Chain) ProgramConverter ¶ added in v1.2.1
ProgramConverter convert program. Only for BCRP now
func (*Chain) SignBlockHeader ¶ added in v1.2.1
func (c *Chain) SignBlockHeader(blockHeader *types.BlockHeader)
type OrphanBlock ¶ added in v1.0.10
func NewOrphanBlock ¶ added in v1.0.10
func NewOrphanBlock(block *types.Block, expiration time.Time) *OrphanBlock
func (*OrphanBlock) Equals ¶ added in v1.0.10
func (o *OrphanBlock) Equals(o1 *OrphanBlock) bool
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 NewOrphanManageWithData ¶ added in v1.0.10
func NewOrphanManageWithData(orphan map[bc.Hash]*OrphanBlock, prevOrphans map[bc.Hash][]*bc.Hash) *OrphanManage
NewOrphanManageWithData return a new orphan manage with specify data
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) Equals ¶ added in v1.0.10
func (o *OrphanManage) Equals(o1 *OrphanManage) bool
func (*OrphanManage) GetPrevOrphans ¶ added in v0.4.6
GetPrevOrphans return the list of child orphans
type TxDesc ¶
type TxDesc struct { Tx *types.Tx `json:"transaction"` Added time.Time `json:"-"` Height uint64 `json:"-"` Weight uint64 `json:"-"` Fee uint64 `json:"-"` }
TxDesc store tx and related info for mining strategy
type TxMsgEvent ¶ added in v1.0.8
type TxMsgEvent struct{ TxMsg *TxPoolMsg }
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool is use for store the unconfirmed transaction
func NewTxPool ¶
func NewTxPool(store state.Store, dispatcher *event.Dispatcher) *TxPool
NewTxPool init a new TxPool
func (*TxPool) AddErrCache ¶
AddErrCache add a failed transaction record to lru cache
func (*TxPool) ExpireOrphan ¶ added in v1.0.5
ExpireOrphan expire all the orphans that before the input time range
func (*TxPool) GetErrCache ¶
GetErrCache return the error of the transaction
func (*TxPool) GetTransaction ¶
GetTransaction return the TxDesc by hash
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) ProcessTransaction ¶ added in v1.0.5
ProcessTransaction is the main entry for txpool handle new tx, ignore dust tx.
func (*TxPool) RemoveTransaction ¶
RemoveTransaction remove a transaction from the pool