Files
nanoreth/crates/revm/revm-inspectors/src/tracing/opcount.rs
Matthias Seitz 14f2b9088e chore: Patch revm to current head commit (#5109)
Co-authored-by: clabby <ben@clab.by>
Co-authored-by: rakita <dragan0rakita@gmail.com>
2023-10-20 19:03:25 +00:00

29 lines
699 B
Rust

//! Opcount tracing inspector that simply counts all opcodes.
//!
//! See also <https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers>
use revm::{interpreter::Interpreter, Database, EVMData, Inspector};
/// An inspector that counts all opcodes.
#[derive(Debug, Clone, Copy, Default)]
pub struct OpcodeCountInspector {
/// opcode counter
count: usize,
}
impl OpcodeCountInspector {
/// Returns the opcode counter
pub fn count(&self) -> usize {
self.count
}
}
impl<DB> Inspector<DB> for OpcodeCountInspector
where
DB: Database,
{
fn step(&mut self, _interp: &mut Interpreter<'_>, _data: &mut EVMData<'_, DB>) {
self.count += 1;
}
}