Skip to content

Commit

Permalink
chore: add missing helpers to BestTransactions (paradigmxyz#12044)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 25, 2024
1 parent ea4fb26 commit 965daba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,15 @@ pub trait BestTransactions: Iterator + Send {
/// listen to pool updates.
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.
///
/// There's only limited blob space available in a block, once exhausted, EIP-4844 transactions
Expand All @@ -762,6 +771,15 @@ pub trait BestTransactions: Iterator + Send {
/// If set to true, no blob transactions will be returned.
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
/// returned by the iterator.
///
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/tests/it/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use reth_transaction_pool::{noop::NoopTransactionPool, BestTransactions, Transac
#[test]
fn test_best_transactions() {
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());
}

0 comments on commit 965daba

Please sign in to comment.