diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 2953d39728..83e3b78c6b 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -420,7 +420,10 @@ where self.pool.get_pooled_transaction_elements(tx_hashes, limit) } - fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option { + fn get_pooled_transaction_element( + &self, + tx_hash: TxHash, + ) -> Option<<::Transaction as PoolTransaction>::Pooled> { self.pool.get_pooled_transaction_element(tx_hash) } diff --git a/crates/transaction-pool/src/noop.rs b/crates/transaction-pool/src/noop.rs index 68e0f98ef8..79901fe18d 100644 --- a/crates/transaction-pool/src/noop.rs +++ b/crates/transaction-pool/src/noop.rs @@ -142,7 +142,7 @@ impl TransactionPool for NoopTransactionPool { fn get_pooled_transaction_element( &self, _tx_hash: TxHash, - ) -> Option { + ) -> Option<::Pooled> { None } diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 69dea90a29..4a035f8e42 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -373,11 +373,11 @@ where pub(crate) fn get_pooled_transaction_element( &self, tx_hash: TxHash, - ) -> Option + ) -> Option<<::Transaction as PoolTransaction>::Pooled> where ::Transaction: EthPoolTransaction, { - self.get(&tx_hash).and_then(|tx| self.to_pooled_transaction(tx).map(Into::into)) + self.get(&tx_hash).and_then(|tx| self.to_pooled_transaction(tx)) } /// Updates the entire pool after a new block was executed. diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 102e137591..742b95cff3 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -233,15 +233,30 @@ pub trait TransactionPool: Send + Sync + Clone { limit: GetPooledTransactionLimit, ) -> Vec; - /// Returns converted [PooledTransactionsElement] for the given transaction hash. + /// Returns the pooled transaction variant for the given transaction hash. /// /// This adheres to the expected behavior of /// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09): /// /// If the transaction is a blob transaction, the sidecar will be included. /// + /// It is expected that this variant represents the valid p2p format for full transactions. + /// E.g. for EIP-4844 transactions this is the consensus transaction format with the blob + /// sidecar. + /// /// Consumer: P2P - fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option; + fn get_pooled_transaction_element( + &self, + tx_hash: TxHash, + ) -> Option<::Pooled>; + + /// Returns the pooled transaction variant for the given transaction hash as the requested type. + fn get_pooled_transaction_as(&self, tx_hash: TxHash) -> Option + where + ::Pooled: Into, + { + self.get_pooled_transaction_element(tx_hash).map(Into::into) + } /// Returns an iterator that yields transactions that are ready for block production. ///