diff --git a/.changelog/fast-seals-play.md b/.changelog/fast-seals-play.md new file mode 100644 index 0000000000..05b056e50a --- /dev/null +++ b/.changelog/fast-seals-play.md @@ -0,0 +1,5 @@ +--- +reth-transaction-pool: minor +--- + +Added `consensus_ref` method to `PoolTransaction` trait for borrowing consensus transactions without cloning. diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index c4b661b796..7955e6c100 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -704,6 +704,10 @@ impl PoolTransaction for MockTransaction { type Pooled = PooledTransactionVariant; + fn consensus_ref(&self) -> Recovered<&Self::Consensus> { + unimplemented!("mock transaction does not wrap a consensus transaction") + } + fn into_consensus(self) -> Recovered { self.into() } diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 6a05e9c421..944e07b171 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -1257,6 +1257,9 @@ pub trait PoolTransaction: self.clone().into_consensus() } + /// Returns a reference to the consensus transaction with the recovered sender. + fn consensus_ref(&self) -> Recovered<&Self::Consensus>; + /// Define a method to convert from the `Self` type to `Consensus` fn into_consensus(self) -> Recovered; @@ -1447,6 +1450,10 @@ impl PoolTransaction for EthPooledTransaction { self.transaction().clone() } + fn consensus_ref(&self) -> Recovered<&Self::Consensus> { + Recovered::new_unchecked(&*self.transaction, self.transaction.signer()) + } + fn into_consensus(self) -> Recovered { self.transaction }