From 961b8c05cd91a57179644c8d9fbd2ae93ee1efad Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Wed, 28 Aug 2024 19:40:53 +0530 Subject: [PATCH] fix: emit trace for unprocessed event only once (#2352) --- crates/torii/core/src/engine.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index 153269bc6e..d6d1510ac5 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -463,6 +463,7 @@ impl Engine

{ *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 @@ -470,6 +471,7 @@ impl Engine

{ || get_selector_from_name(&processor.event_key())? == event.keys[0]) && processor.validate(event) { + unprocessed = false; if let Err(e) = processor .process( &self.world, @@ -484,20 +486,22 @@ impl Engine

{ { 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(()) } }