reth_transaction_pool/pool/
events.rs1use crate::{traits::PropagateKind, PoolTransaction, SubPool, ValidPoolTransaction};
2use alloy_primitives::{TxHash, B256};
3use std::sync::Arc;
4
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug)]
10pub enum FullTransactionEvent<T: PoolTransaction> {
11 Pending(TxHash),
13 Queued(TxHash),
15 Mined {
17 tx_hash: TxHash,
19 block_hash: B256,
21 },
22 Replaced {
26 transaction: Arc<ValidPoolTransaction<T>>,
28 replaced_by: TxHash,
30 },
31 Discarded(TxHash),
33 Invalid(TxHash),
35 Propagated(Arc<Vec<PropagateKind>>),
37}
38
39impl<T: PoolTransaction> Clone for FullTransactionEvent<T> {
40 fn clone(&self) -> Self {
41 match self {
42 Self::Pending(hash) => Self::Pending(*hash),
43 Self::Queued(hash) => Self::Queued(*hash),
44 Self::Mined { tx_hash, block_hash } => {
45 Self::Mined { tx_hash: *tx_hash, block_hash: *block_hash }
46 }
47 Self::Replaced { transaction, replaced_by } => {
48 Self::Replaced { transaction: Arc::clone(transaction), replaced_by: *replaced_by }
49 }
50 Self::Discarded(hash) => Self::Discarded(*hash),
51 Self::Invalid(hash) => Self::Invalid(*hash),
52 Self::Propagated(propagated) => Self::Propagated(Arc::clone(propagated)),
53 }
54 }
55}
56
57#[derive(Debug, Clone, Eq, PartialEq)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub enum TransactionEvent {
61 Pending,
63 Queued,
65 Mined(B256),
67 Replaced(TxHash),
71 Discarded,
73 Invalid,
75 Propagated(Arc<Vec<PropagateKind>>),
77}
78
79impl TransactionEvent {
80 pub const fn is_final(&self) -> bool {
83 matches!(self, Self::Replaced(_) | Self::Mined(_) | Self::Discarded)
84 }
85}
86
87#[derive(Debug)]
89pub struct NewTransactionEvent<T: PoolTransaction> {
90 pub subpool: SubPool,
92 pub transaction: Arc<ValidPoolTransaction<T>>,
94}
95
96impl<T: PoolTransaction> Clone for NewTransactionEvent<T> {
97 fn clone(&self) -> Self {
98 Self { subpool: self.subpool, transaction: self.transaction.clone() }
99 }
100}