mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add missing helpers to BestTransactions (#12044)
This commit is contained in:
@ -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.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -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());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user