mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
29 lines
699 B
Rust
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;
|
|
}
|
|
}
|