Skip to content

Commit

Permalink
feat: Inspector::log (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg authored Mar 19, 2022
1 parent 7a5a2cd commit cb5fbb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ impl<'a, GSPEC: Spec, DB: Database + 'a, const INSPECT: bool> Host
}

fn log(&mut self, address: H160, topics: Vec<H256>, data: Bytes) {
if INSPECT {
self.inspector.log(&mut self.data, &address, &topics, &data);
}
let log = Log {
address,
topics,
Expand Down
12 changes: 11 additions & 1 deletion crates/revm/src/inspector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bytes::Bytes;
use primitive_types::H160;
use primitive_types::{H160, H256};

use crate::{evm_impl::EVMData, CallInputs, CreateInputs, Database, Gas, Interpreter, Return};
use auto_impl::auto_impl;
Expand Down Expand Up @@ -36,6 +36,16 @@ pub trait Inspector<DB: Database> {
Return::Continue
}

/// Called when a log is emitted.
fn log(
&mut self,
_evm_data: &mut EVMData<'_, DB>,
_address: &H160,
_topics: &[H256],
_data: &Bytes,
) {
}

/// Called after `step` when the instruction has been executed.
///
/// Returning anything other than [Return::Continue] alters the execution of the interpreter.
Expand Down

0 comments on commit cb5fbb9

Please sign in to comment.