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