feat(txpool): add PoolTransaction::consensus_ref (#22182)

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Georgios Konstantopoulos
2026-02-15 04:23:37 -08:00
committed by GitHub
parent 2be3788481
commit d71a0c0c7b
3 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
reth-transaction-pool: minor
---
Added `consensus_ref` method to `PoolTransaction` trait for borrowing consensus transactions without cloning.

View File

@@ -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::Consensus> {
self.into()
}

View File

@@ -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<Self::Consensus>;
@@ -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::Consensus> {
self.transaction
}