Skip to content

Commit

Permalink
fix: emit trace for unprocessed event only once
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed Aug 28, 2024
1 parent e1a349b commit 5c16c28
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,15 @@ impl<P: Provider + Sync> Engine<P> {
*transaction_receipt.receipt.transaction_hash(),
block_timestamp,
);
let mut unprocessed = true;
for processor in &self.processors.event {
// If the processor has no event_key, means it's a catch-all processor.
// We also validate the event
if (processor.event_key().is_empty()
|| get_selector_from_name(&processor.event_key())? == event.keys[0])
&& processor.validate(event)
{
unprocessed = false;
if let Err(e) = processor
.process(
&self.world,
Expand All @@ -484,20 +486,22 @@ impl<P: Provider + Sync> Engine<P> {
{
error!(target: LOG_TARGET, event_name = processor.event_key(), error = %e, "Processing event.");
}
} else {
let unprocessed_event = UnprocessedEvent {
keys: event.keys.iter().map(|k| format!("{:#x}", k)).collect(),
data: event.data.iter().map(|d| format!("{:#x}", d)).collect(),
};

trace!(
target: LOG_TARGET,
keys = ?unprocessed_event.keys,
data = ?unprocessed_event.data,
"Unprocessed event.",
);
}
}

if unprocessed {
let unprocessed_event = UnprocessedEvent {
keys: event.keys.iter().map(|k| format!("{:#x}", k)).collect(),
data: event.data.iter().map(|d| format!("{:#x}", d)).collect(),
};

trace!(
target: LOG_TARGET,
keys = ?unprocessed_event.keys,
data = ?unprocessed_event.data,
"Unprocessed event.",

Check warning on line 502 in crates/torii/core/src/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/engine.rs#L502

Added line #L502 was not covered by tests
);
}
Ok(())
}
}

0 comments on commit 5c16c28

Please sign in to comment.