diff --git a/crates/evm/src/block/mod.rs b/crates/evm/src/block/mod.rs index b4bfe450..b9f1e25c 100644 --- a/crates/evm/src/block/mod.rs +++ b/crates/evm/src/block/mod.rs @@ -318,6 +318,29 @@ pub trait BlockExecutor { self.apply_post_execution_changes() } + + /// Like [`execute_block`], but with a custom closure to process each transaction. + /// + /// For instance, this enables capturing per-transaction performance metrics. + fn execute_block_with_transaction_closure( + mut self, + transactions: impl IntoIterator>, + mut f: F, + ) -> Result<(Self::Evm, BlockExecutionResult), BlockExecutionError> + where + Self: Sized, + Tx: ExecutableTx, + F: FnMut(&mut Self, Tx) -> Result, + { + self.apply_pre_execution_changes()?; + + for tx in transactions { + let tx = tx?; + f(&mut self, tx)?; + } + + self.finish() + } } /// A helper trait encapsulating the constraints on [`BlockExecutor`] produced by the