diff --git a/src/pool/step.rs b/src/pool/step.rs index 95f295b..5f9ed17 100644 --- a/src/pool/step.rs +++ b/src/pool/step.rs @@ -67,6 +67,13 @@ pub struct AppendOrders { /// Defaults to `true`. break_on_limit: bool, + /// Custom filters that can reject orders based on arbitrary criteria. + /// Each filter is a function that takes the current payload checkpoint and + /// an order, and returns true if the order should be included and false if + /// it should be skipped. + #[expect(clippy::type_complexity)] + filters: Vec, &Order

) -> bool + Send + Sync>>, + metrics: Metrics, per_job: PerJobCounters, } @@ -83,6 +90,7 @@ impl AppendOrders

{ max_new_bundles: None, max_new_transactions: None, break_on_limit: true, + filters: Vec::new(), metrics: Metrics::default(), per_job: PerJobCounters::default(), } @@ -128,6 +136,16 @@ impl AppendOrders

{ self.break_on_limit = false; self } + + /// Adds a custom filter that can reject orders based on arbitrary criteria. + #[must_use] + pub fn with_filter( + mut self, + filter: impl Fn(&Checkpoint

, &Order

) -> bool + Send + Sync + 'static, + ) -> Self { + self.filters.push(Box::new(filter)); + self + } } impl Step

for AppendOrders

{ @@ -323,6 +341,14 @@ impl<'a, P: Platform> Run<'a, P> { return true; } + // Check custom filters + for filter in &self.step.filters { + if !filter(&self.payload, order) { + // Custom filter rejected this order + return true; + } + } + let order_blob_gas = order .transactions() .iter()