Documentation ¶
Index ¶
- Constants
- Variables
- func IsMetrics() bool
- func IsTxTimeVerify(chainConf protocol.ChainConf) bool
- func MaxCommonTxPoolSize() int
- func MaxConfigTxPoolSize() int
- func MaxTxCount(chainConf protocol.ChainConf) int
- func MaxTxTimeTimeout(chainConf protocol.ChainConf) float64
- func NewBatchTxPool(nodeId string, chainId string, txFilter protocol.TxFilter, ...) (protocol.TxPool, error)
- type BatchTxPool
- func (p *BatchTxPool) AddTx(tx *commonPb.Transaction, src protocol.TxSource) error
- func (p *BatchTxPool) AddTxsToPendingCache(txs []*commonPb.Transaction, blockHeight uint64)
- func (p *BatchTxPool) Apply(opts ...Option) error
- func (p *BatchTxPool) FetchTxBatch(blockHeight uint64) []*commonPb.Transaction
- func (p *BatchTxPool) GetTxByTxId(txId string) (tx *commonPb.Transaction, inBlockHeight uint64)
- func (p *BatchTxPool) GetTxsByTxIds(txIds []string) (map[string]*commonPb.Transaction, map[string]uint64)
- func (p *BatchTxPool) OnMessage(message *msgbus.Message)
- func (p *BatchTxPool) OnQuit()
- func (p *BatchTxPool) RetryAndRemoveTxs(retryTxs []*commonPb.Transaction, removeTxs []*commonPb.Transaction)
- func (p *BatchTxPool) SetBatchCreateTimeout(timeout time.Duration)
- func (p *BatchTxPool) SetBatchMaxSize(size int)
- func (p *BatchTxPool) SetMsgBus(msgBus msgbus.MessageBus)
- func (p *BatchTxPool) SetPoolSize(size int)
- func (p *BatchTxPool) Start() error
- func (p *BatchTxPool) Stop() error
- func (p *BatchTxPool) TxExists(tx *commonPb.Transaction) bool
- type Option
Constants ¶
const ( DefaultBatchMaxSize = 100 DefaultBatchCreateTimeout = 1000 * time.Millisecond DefaultPoolSize = 10000 TxPoolType = "BATCH" )
const ( DefaultMaxTxCount = 1000 // Maximum number of transactions in a block DefaultMaxTxPoolSize = 5120 // Maximum number of common transaction in the pool DefaultMaxConfigTxPoolSize = 100 // Maximum number of config transaction in the pool DefaultMaxTxTimeTimeout = float64(600) // The unit is in seconds )
Variables ¶
var ( TxPoolConfig *txPoolConfig MonitorEnabled bool )
Functions ¶
func IsTxTimeVerify ¶
IsTxTimeVerify Whether transactions require validation
func MaxCommonTxPoolSize ¶
func MaxCommonTxPoolSize() int
MaxCommonTxPoolSize Maximum number of common transaction in the pool
func MaxConfigTxPoolSize ¶
func MaxConfigTxPoolSize() int
MaxConfigTxPoolSize The maximum number of configure transaction in the pool
func MaxTxCount ¶
MaxTxCount Maximum number of transactions in a block
func MaxTxTimeTimeout ¶
MaxTxTimeTimeout The maximum timeout for a transaction
func NewBatchTxPool ¶
func NewBatchTxPool( nodeId string, chainId string, txFilter protocol.TxFilter, chainStore protocol.BlockchainStore, msgBus msgbus.MessageBus, chainConf protocol.ChainConf, ac protocol.AccessControlProvider, log protocol.Logger, monitorEnabled bool, poolConfig map[string]interface{}) (protocol.TxPool, error)
NewBatchTxPool creates BatchTxPool
Types ¶
type BatchTxPool ¶
type BatchTxPool struct {
// contains filtered or unexported fields
}
BatchTxPool Another implementation of tx pool, which can only be used in non-Hotstuff consensus algorithms
func (*BatchTxPool) AddTx ¶
func (p *BatchTxPool) AddTx(tx *commonPb.Transaction, src protocol.TxSource) error
AddTx add tx to pool
func (*BatchTxPool) AddTxsToPendingCache ¶
func (p *BatchTxPool) AddTxsToPendingCache(txs []*commonPb.Transaction, blockHeight uint64)
AddTxsToPendingCache These transactions will be added to the cache to avoid the transactions are fetched again and re-filled into the new block. Because Because of the chain confirmation rule in the HotStuff consensus algorithm.
func (*BatchTxPool) Apply ¶
func (p *BatchTxPool) Apply(opts ...Option) error
Apply apply txPool config
func (*BatchTxPool) FetchTxBatch ¶
func (p *BatchTxPool) FetchTxBatch(blockHeight uint64) []*commonPb.Transaction
FetchTxBatch Get the batch of transactions from the tx pool to generate new block
func (*BatchTxPool) GetTxByTxId ¶
func (p *BatchTxPool) GetTxByTxId(txId string) (tx *commonPb.Transaction, inBlockHeight uint64)
GetTxByTxId Retrieve the transaction by the txId from the txPool
func (*BatchTxPool) GetTxsByTxIds ¶
func (p *BatchTxPool) GetTxsByTxIds(txIds []string) (map[string]*commonPb.Transaction, map[string]uint64)
GetTxsByTxIds Retrieves the tx by the txIds from the tx pool. txsRet if the transaction is in the tx pool, it will be returned in txsRet. txsHeightRet if the transaction is in the pending queue of the tx pool, the corresponding block height when the transaction entered the block is returned, if the transaction is in the normal queue of the tx pool, the tx height is 0, if the transaction is not in the transaction pool, the tx height is math.MaxUint64.
func (*BatchTxPool) OnMessage ¶
func (p *BatchTxPool) OnMessage(message *msgbus.Message)
OnMessage receive msg from msgBus
func (*BatchTxPool) OnQuit ¶
func (p *BatchTxPool) OnQuit()
func (*BatchTxPool) RetryAndRemoveTxs ¶
func (p *BatchTxPool) RetryAndRemoveTxs(retryTxs []*commonPb.Transaction, removeTxs []*commonPb.Transaction)
RetryAndRemoveTxs Process transactions within multiple proposed blocks at the same height to ensure that these transactions are not lost, re-add valid txs which that are not on local node. remove txs in the commit block.
func (*BatchTxPool) SetBatchCreateTimeout ¶
func (p *BatchTxPool) SetBatchCreateTimeout(timeout time.Duration)
SetBatchCreateTimeout set batchCreateTimeout
func (*BatchTxPool) SetBatchMaxSize ¶
func (p *BatchTxPool) SetBatchMaxSize(size int)
SetBatchMaxSize set batchMaxSize
func (*BatchTxPool) SetMsgBus ¶
func (p *BatchTxPool) SetMsgBus(msgBus msgbus.MessageBus)
SetMsgBus set msgBus
func (*BatchTxPool) SetPoolSize ¶
func (p *BatchTxPool) SetPoolSize(size int)
SetPoolSize set poolSize
func (*BatchTxPool) TxExists ¶
func (p *BatchTxPool) TxExists(tx *commonPb.Transaction) bool
TxExists verifies whether the transaction exists in the tx_pool
type Option ¶
type Option func(p *BatchTxPool) error
Option is txPool config Options
func WithBatchCreateTimeout ¶
WithBatchCreateTimeout set batchCreateTimeout