Skip to content

Commit

Permalink
fix: emit trace for unprocessed event only once (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x authored Aug 28, 2024
1 parent 3d8b3ba commit 961b8c0
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.",
);
}
Ok(())
}
}

0 comments on commit 961b8c0

Please sign in to comment.