From 95ebf646a1d075cc1ed58e14c3d1af325caeb98a Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Sun, 22 Sep 2024 23:50:22 +0530 Subject: [PATCH] fix(torii): improve log messages commit-id:88796bb8 --- crates/torii/core/src/engine.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index f24180ad44..9f1131b149 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -18,7 +18,7 @@ use tokio::sync::broadcast::Sender; use tokio::sync::mpsc::Sender as BoundedSender; use tokio::sync::Semaphore; use tokio::task::JoinSet; -use tokio::time::sleep; +use tokio::time::{sleep, Instant}; use tracing::{debug, error, info, trace, warn}; use crate::processors::event_message::EventMessageProcessor; @@ -171,6 +171,7 @@ impl Engine

{ res = self.fetch_data(head, last_pending_block_world_tx, last_pending_block_tx) => { match res { Ok(fetch_result) => { + let instant = Instant::now(); if erroring_out { erroring_out = false; backoff_delay = Duration::from_secs(1); @@ -188,6 +189,7 @@ impl Engine

{ } } } + debug!(target: LOG_TARGET, duration = ?instant.elapsed(), "Processed fetched data."); } Err(e) => { erroring_out = true; @@ -210,16 +212,18 @@ impl Engine

{ last_pending_block_world_tx: Option, last_pending_block_tx: Option, ) -> Result { + let instant = Instant::now(); let latest_block_number = self.provider.block_hash_and_number().await?.block_number; let result = if from < latest_block_number { let from = if from == 0 { from } else { from + 1 }; - debug!(target: LOG_TARGET, from = %from, to = %latest_block_number, "Fetching data for range."); let data = self.fetch_range(from, latest_block_number, last_pending_block_world_tx).await?; + debug!(target: LOG_TARGET, duration = ?instant.elapsed(), from = %from, to = %latest_block_number, "Fetched data for range."); FetchDataResult::Range(data) } else if self.config.index_pending { let data = self.fetch_pending(latest_block_number + 1, last_pending_block_tx).await?; + debug!(target: LOG_TARGET, duration = ?instant.elapsed(), latest_block_number = %latest_block_number, "Fetched pending data."); if let Some(data) = data { FetchDataResult::Pending(data) } else {