reth_transaction_pool/pool/
update.rs

1//! Support types for updating the pool.
2
3use crate::{
4    identifier::TransactionId, pool::state::SubPool, PoolTransaction, ValidPoolTransaction,
5};
6use alloy_primitives::TxHash;
7use std::sync::Arc;
8
9/// A change of the transaction's location
10///
11/// NOTE: this guarantees that `current` and `destination` differ.
12#[derive(Debug)]
13pub(crate) struct PoolUpdate {
14    /// Internal tx id.
15    pub(crate) id: TransactionId,
16    /// Hash of the transaction.
17    pub(crate) hash: TxHash,
18    /// Where the transaction is currently held.
19    pub(crate) current: SubPool,
20    /// Where to move the transaction to.
21    pub(crate) destination: Destination,
22}
23
24/// Where to move an existing transaction.
25#[derive(Debug)]
26pub(crate) enum Destination {
27    /// Discard the transaction.
28    Discard,
29    /// Move transaction to pool
30    Pool(SubPool),
31}
32
33impl From<SubPool> for Destination {
34    fn from(sub_pool: SubPool) -> Self {
35        Self::Pool(sub_pool)
36    }
37}
38
39/// Tracks the result after updating the pool
40#[derive(Debug)]
41pub(crate) struct UpdateOutcome<T: PoolTransaction> {
42    /// transactions promoted to the pending pool
43    pub(crate) promoted: Vec<Arc<ValidPoolTransaction<T>>>,
44    /// transaction that failed and were discarded
45    pub(crate) discarded: Vec<Arc<ValidPoolTransaction<T>>>,
46}
47
48impl<T: PoolTransaction> Default for UpdateOutcome<T> {
49    fn default() -> Self {
50        Self { promoted: vec![], discarded: vec![] }
51    }
52}