Struct TransactionPool

Source
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

Source

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.

Source

pub fn add( &mut self, tx_hash: TransactionHash, tx: OwnedTransaction, ) -> Result<(), TransactionAddError>

Add new transaction to the pool

Source

pub fn mark_authorized( &mut self, tx_hash: &TransactionHash, block_number: BlockNumber, block_hash: BlockHash, ) -> bool

Mark transaction as authorized as of a specific block.

Returns false if transaction is unknown.

Source

pub fn contains(&self, tx_hash: &TransactionHash) -> bool

Whether transaction pool contains a transaction

Source

pub fn iter( &self, ) -> impl ExactSizeIterator<Item = (&TransactionHash, &PoolTransaction)> + '_

Get iterator over all transactions

Source

pub fn remove<'a, Txs>(&mut self, tx_hashes: Txs)
where Txs: Iterator<Item = &'a TransactionHash>,

Remove transactions from the pool

Source

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.

Trait Implementations§

Source§

impl Debug for TransactionPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.