Documentation ¶
Index ¶
- Variables
- type BlockTimeBucket
- type BlocksTrie
- type HashSet
- type NodeByHash
- type RecentTx
- func (recent *RecentTx) GetTrace(txs []*types.Transaction) map[common.Hash]TxTrace
- func (recent *RecentTx) IsExist(tx *types.Transaction) bool
- func (recent *RecentTx) PruneBlock(hash common.Hash, height int64, txs []*types.Transaction)
- func (recent *RecentTx) RecvBlock(hash common.Hash, height int64, txs []*types.Transaction)
- func (recent *RecentTx) RecvTx(tx *types.Transaction)
- type TrieNode
- type TxPool
- func (pool *TxPool) DelInvalidTxs(txs []*types.Transaction)
- func (pool *TxPool) Get(time uint32, size int) []*types.Transaction
- func (pool *TxPool) PruneBlock(block *types.Block)
- func (pool *TxPool) RecvBlock(block *types.Block)
- func (pool *TxPool) RecvTx(tx *types.Transaction) bool
- func (pool *TxPool) RecvTxs(txs []*types.Transaction) bool
- func (pool *TxPool) VerifyTxInBlock(block *types.Block) bool
- type TxQueue
- type TxTimeBucket
- type TxTrace
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTxPoolBlockExpired = errors.New("the block has expired")
Functions ¶
This section is empty.
Types ¶
type BlockTimeBucket ¶
type BlocksTrie ¶
type BlocksTrie struct { /* 根据高度对块进行索引 */ HeightBuckets map[uint32]NodeByHash /* 根据时间刻度对块Hash进行索引,用来回收块 */ TimeBuckets []*BlockTimeBucket }
最近一个小时的所有块
func NewBlocksTrie ¶
func NewBlocksTrie() *BlocksTrie
func (*BlocksTrie) DelBlock ¶
func (trie *BlocksTrie) DelBlock(block *types.Block)
type NodeByHash ¶
type RecentTx ¶
type RecentTx struct { // key是交易hash,value是交易所在块的记录 TraceMap map[common.Hash]TxTrace TxsByTime []*TxTimeBucket }
近一个小时收到的所有交易的集合,用于防止交易重放
func NewTxRecently ¶
func NewTxRecently() *RecentTx
func (*RecentTx) PruneBlock ¶
type TxPool ¶
type TxPool struct { /* 还未被打包进块的交易 */ PendingTxs *TxQueue /* 最近1个小时的所有交易 */ RecentTxs *RecentTx /* 从当前高度向后的3600个块 */ BlockCache *BlocksTrie RW sync.RWMutex }
func (*TxPool) DelInvalidTxs ¶
func (pool *TxPool) DelInvalidTxs(txs []*types.Transaction)
本节点出块时,执行交易后,发现错误的交易通过该接口进行删除
func (*TxPool) Get ¶
func (pool *TxPool) Get(time uint32, size int) []*types.Transaction
本节点出块时,从交易池中取出交易进行打包,但并不从交易池中删除
func (*TxPool) PruneBlock ¶
对链进行剪枝,剪下的块中的交易需要回归交易池
type TxQueue ¶
type TxQueue struct { /* 交易状态标记,true:正常;false:已删除 */ TxsStatus map[common.Hash]bool TxsQueue []*types.Transaction }
func NewTxQueue ¶
func NewTxQueue() *TxQueue
func (*TxQueue) Push ¶
func (queue *TxQueue) Push(tx *types.Transaction)
func (*TxQueue) PushBatch ¶
func (queue *TxQueue) PushBatch(txs []*types.Transaction)
type TxTimeBucket ¶
Click to show internal directories.
Click to hide internal directories.