pub struct TransactionPool { /* private fields */ }
Expand description
Transaction pool implementation.
The goal of the transaction pool is to retain a set of transactions and associated authorization information, which can be used for block production and propagation through the network.
Implementations§
Source§impl TransactionPool
impl TransactionPool
Sourcepub fn new(
pruning_depth: NonZeroU64,
authorization_history_depth: NonZeroU8,
limits: TransactionPoolLimits,
) -> Self
pub fn new( pruning_depth: NonZeroU64, authorization_history_depth: NonZeroU8, limits: TransactionPoolLimits, ) -> Self
Create new instance.
pruning_depth
defines how old (in blocks) should transaction be before it is automatically
removed from the transaction pool.
authorization_history_depth
defines a small number of recent blocks for which
authorization information is retained in each block.
limits
defines the limits of transaction pool.
Sourcepub fn add(
&mut self,
tx_hash: TransactionHash,
tx: OwnedTransaction,
) -> Result<(), TransactionAddError>
pub fn add( &mut self, tx_hash: TransactionHash, tx: OwnedTransaction, ) -> Result<(), TransactionAddError>
Add new transaction to the pool
Mark transaction as authorized as of a specific block.
Returns false
if transaction is unknown.
Sourcepub fn contains(&self, tx_hash: &TransactionHash) -> bool
pub fn contains(&self, tx_hash: &TransactionHash) -> bool
Whether transaction pool contains a transaction
Sourcepub fn iter(
&self,
) -> impl ExactSizeIterator<Item = (&TransactionHash, &PoolTransaction)> + '_
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = (&TransactionHash, &PoolTransaction)> + '_
Get iterator over all transactions
Sourcepub fn remove<'a, Txs>(&mut self, tx_hashes: Txs)where
Txs: Iterator<Item = &'a TransactionHash>,
pub fn remove<'a, Txs>(&mut self, tx_hashes: Txs)where
Txs: Iterator<Item = &'a TransactionHash>,
Remove transactions from the pool
Sourcepub fn add_best_block(
&mut self,
block_number: BlockNumber,
block_hash: BlockHash,
)
pub fn add_best_block( &mut self, block_number: BlockNumber, block_hash: BlockHash, )
Add the new best block.
If there is already an existing block with the same or higher block number, it will be removed alongside all transactions. Blocks older than configured pruning depth will be removed automatically as well.
This allows accepting transactions created at specified block hash.