From d71a0c0c7b4c93e82b67c2b324f5d4e8987c3930 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sun, 15 Feb 2026 04:23:37 -0800 Subject: [PATCH] feat(txpool): add PoolTransaction::consensus_ref (#22182) Co-authored-by: Amp Co-authored-by: Matthias Seitz --- .changelog/fast-seals-play.md | 5 +++++ crates/transaction-pool/src/test_utils/mock.rs | 4 ++++ crates/transaction-pool/src/traits.rs | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 .changelog/fast-seals-play.md 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 }