diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 8d11d7595b14..3194ebba6f8b 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -409,7 +409,7 @@ where &self, max: usize, ) -> Vec>> { - self.pooled_transactions().into_iter().take(max).collect() + self.pool.pooled_transactions_max(max) } fn get_pooled_transaction_elements( diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 3f7ecfa7836f..8c17da783acf 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -304,6 +304,14 @@ where self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).collect() } + /// Returns only the first `max` transactions in the pool. + pub(crate) fn pooled_transactions_max( + &self, + max: usize, + ) -> Vec>> { + self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).take(max).collect() + } + /// Returns the [`BlobTransaction`] for the given transaction if the sidecar exists. /// /// Caution: this assumes the given transaction is eip-4844