mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add BestTransactions::filter_transactions (#12041)
This commit is contained in:
@ -761,6 +761,19 @@ 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);
|
||||||
|
|
||||||
|
/// Creates an iterator which uses a closure to determine whether a transaction should be
|
||||||
|
/// returned by the iterator.
|
||||||
|
///
|
||||||
|
/// All items the closure returns false for are marked as invalid via [`Self::mark_invalid`] and
|
||||||
|
/// descendant transactions will be skipped.
|
||||||
|
fn filter_transactions<P>(self, predicate: P) -> BestTransactionFilter<Self, P>
|
||||||
|
where
|
||||||
|
P: FnMut(&Self::Item) -> bool,
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
BestTransactionFilter::new(self, predicate)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> BestTransactions for Box<T>
|
impl<T> BestTransactions for Box<T>
|
||||||
|
|||||||
10
crates/transaction-pool/tests/it/best.rs
Normal file
10
crates/transaction-pool/tests/it/best.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//! Best transaction and filter testing
|
||||||
|
|
||||||
|
use reth_transaction_pool::{noop::NoopTransactionPool, BestTransactions, TransactionPool};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_best_transactions() {
|
||||||
|
let noop = NoopTransactionPool::default();
|
||||||
|
let mut best = noop.best_transactions().filter_transactions(|_| true);
|
||||||
|
assert!(best.next().is_none());
|
||||||
|
}
|
||||||
@ -9,4 +9,6 @@ mod listeners;
|
|||||||
#[cfg(feature = "test-utils")]
|
#[cfg(feature = "test-utils")]
|
||||||
mod pending;
|
mod pending;
|
||||||
|
|
||||||
|
mod best;
|
||||||
|
|
||||||
const fn main() {}
|
const fn main() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user