chore: add missing helpers to BestTransactions (#12044)

This commit is contained in:
Matthias Seitz
2024-10-25 05:57:09 +02:00
committed by GitHub
parent ea4fb26063
commit 965dabacad
2 changed files with 20 additions and 1 deletions

View File

@ -747,6 +747,15 @@ pub trait BestTransactions: Iterator + Send {
/// listen to pool updates. /// listen to pool updates.
fn no_updates(&mut self); fn no_updates(&mut self);
/// Convenience function for [`Self::no_updates`] that returns the iterator again.
fn without_updates(mut self) -> Self
where
Self: Sized,
{
self.no_updates();
self
}
/// Skip all blob transactions. /// Skip all blob transactions.
/// ///
/// There's only limited blob space available in a block, once exhausted, EIP-4844 transactions /// There's only limited blob space available in a block, once exhausted, EIP-4844 transactions
@ -762,6 +771,15 @@ pub trait BestTransactions: Iterator + Send {
/// If set to true, no blob transactions will be returned. /// If set to true, no blob transactions will be returned.
fn set_skip_blobs(&mut self, skip_blobs: bool); fn set_skip_blobs(&mut self, skip_blobs: bool);
/// Convenience function for [`Self::skip_blobs`] that returns the iterator again.
fn without_blobs(mut self) -> Self
where
Self: Sized,
{
self.skip_blobs();
self
}
/// Creates an iterator which uses a closure to determine whether a transaction should be /// Creates an iterator which uses a closure to determine whether a transaction should be
/// returned by the iterator. /// returned by the iterator.
/// ///

View File

@ -5,6 +5,7 @@ use reth_transaction_pool::{noop::NoopTransactionPool, BestTransactions, Transac
#[test] #[test]
fn test_best_transactions() { fn test_best_transactions() {
let noop = NoopTransactionPool::default(); let noop = NoopTransactionPool::default();
let mut best = noop.best_transactions().filter_transactions(|_| true); let mut best =
noop.best_transactions().filter_transactions(|_| true).without_blobs().without_updates();
assert!(best.next().is_none()); assert!(best.next().is_none());
} }