Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/evm/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,28 @@ 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<F, Tx>(
mut self,
transactions: impl IntoIterator<Item = Tx>,
mut f: F,
) -> Result<(Self::Evm, BlockExecutionResult<Self::Receipt>), BlockExecutionError>
where
Self: Sized,
Tx: ExecutableTx<Self>,
F: FnMut(&mut Self, Tx) -> Result<u64, BlockExecutionError>,
{
self.apply_pre_execution_changes()?;

for tx in transactions {
f(&mut self, tx)?;
}

self.finish()
}
}

/// A helper trait encapsulating the constraints on [`BlockExecutor`] produced by the
Expand Down