Documentation ¶
Index ¶
- Constants
- Variables
- type BlockCache
- func (cache BlockCache) Add(block *types.Block)
- func (cache BlockCache) CollectBlocks(blockHashSet HashSet) (BlockNodes, error)
- func (cache BlockCache) Del(hash common.Hash)
- func (cache BlockCache) Get(hash common.Hash) *BlockNode
- func (cache BlockCache) IsAppearedOnFork(blockHashes HashSet, startBlockHash common.Hash) bool
- func (cache BlockCache) SliceOnFork(startBlockHash common.Hash, minHeight uint32, maxHeight uint32) (blockHashes []common.Hash, err error)
- type BlockNode
- type BlockNodes
- type HashList
- type HashSet
- type TimeBuckets
- type TxGuard
- func (guard *TxGuard) DelOldBlocks(newStableBlockTime uint32)
- func (guard *TxGuard) ExistTx(startBlockHash common.Hash, tx *types.Transaction) bool
- func (guard *TxGuard) ExistTxs(startBlockHash common.Hash, txs types.Transactions) bool
- func (guard *TxGuard) GetTxsByBranch(block1, block2 *types.Block) (txs1, txs2 types.Transactions, err error)
- func (guard *TxGuard) SaveBlock(block *types.Block)
- type TxPool
- type TxTracer
Constants ¶
const BucketDuration = uint32(60)
TimeBuckets中每一个slot覆盖的时间范围,单位为秒
Variables ¶
var ( ErrNotFoundBlockCache = errors.New("not found block in TxGuard'Cache") ErrTimeBucketTime = errors.New("block timestamp should be greater than bucket base time") ErrDifferentGenesis = errors.New("found different genesis block") ErrInvalidTx = errors.New("the transaction is broken") ErrTxIsExist = errors.New("the transaction is exist in txPool") ErrTxPoolExtendFail = errors.New("txPool extend fail") ErrInvalidBaseTime = errors.New("invalid stable block time") )
Functions ¶
This section is empty.
Types ¶
type BlockCache ¶ added in v1.4.0
根据区块Hash索引区块
func (BlockCache) Add ¶ added in v1.4.0
func (cache BlockCache) Add(block *types.Block)
func (BlockCache) CollectBlocks ¶ added in v1.4.0
func (cache BlockCache) CollectBlocks(blockHashSet HashSet) (BlockNodes, error)
SliceOnFork collect blocks' hashes from specific fork and specific height range [minHeight, maxHeight]
func (BlockCache) Del ¶ added in v1.4.0
func (cache BlockCache) Del(hash common.Hash)
func (BlockCache) IsAppearedOnFork ¶ added in v1.4.0
func (cache BlockCache) IsAppearedOnFork(blockHashes HashSet, startBlockHash common.Hash) bool
IsAppearedOnFork tests if the blocks are appeared on the fork from startBlock
func (BlockCache) SliceOnFork ¶ added in v1.4.0
func (cache BlockCache) SliceOnFork(startBlockHash common.Hash, minHeight uint32, maxHeight uint32) (blockHashes []common.Hash, err error)
SliceOnFork collect blocks' hashes from specific fork and specific height range [minHeight, maxHeight]. The result array is from leaf block hash to root block hash
type BlockNode ¶ added in v1.4.0
type BlockNode struct { Header *types.Header /* 该块打包的交易列表 */ Txs types.Transactions }
简化的区块数据
type BlockNodes ¶ added in v1.4.0
type BlockNodes []*BlockNode
type TimeBuckets ¶ added in v1.4.0
type TimeBuckets struct { // 第一个bucket的起始时间,是BucketDuration的整数倍。此时间戳是随着链上的stable变化而变化的 TimeBase uint32 // contains filtered or unexported fields }
type TxGuard ¶ added in v1.4.0
TxGuard is used test if a transaction or block is contained in some fork It contains the blocks half hour before stable block, and contains unstable blocks
func NewTxGuard ¶ added in v1.4.0
func (*TxGuard) DelOldBlocks ¶ added in v1.4.0
DelOldBlocks 根据时间删去过期了的区块和交易
func (*TxGuard) ExistTxs ¶ added in v1.4.0
ExistTxs 判断txs中是否有交易已经在当前分支存在,startBlockHash为指定分支的子节点的区块hash
func (*TxGuard) GetTxsByBranch ¶ added in v1.4.0
func (guard *TxGuard) GetTxsByBranch(block1, block2 *types.Block) (txs1, txs2 types.Transactions, err error)
GetTxsByBranch 根据两个区块的叶子节点,获取它们到共同父节点之间的两个分支上的交易列表
type TxPool ¶
TxPool saves the transactions which could be packaged in current fork
func (*TxPool) AddTxs ¶ added in v1.4.0
func (pool *TxPool) AddTxs(txs types.Transactions) int
AddTxs push txs into pool and return the number of new txs
func (*TxPool) DelTxs ¶ added in v1.4.0
func (pool *TxPool) DelTxs(txs types.Transactions)
新收到一个通过验证的新块(包括本节点出的块),需要从交易池中删除该块中已打包的交易
type TxTracer ¶ added in v1.4.0
TxTracer use transaction hash to be the key, and the value is block hashes which the transaction appeared
func (TxTracer) AddTrace ¶ added in v1.4.0
func (t TxTracer) AddTrace(tx *types.Transaction, blockHash common.Hash)
func (TxTracer) DelTrace ¶ added in v1.4.0
func (t TxTracer) DelTrace(tx *types.Transaction)
func (TxTracer) LoadTraces ¶ added in v1.4.0
func (t TxTracer) LoadTraces(txs types.Transactions) HashSet
loadTraces load the block hash list which txs appeared