Skip to content

Commit

Permalink
Temporarily log block lag
Browse files Browse the repository at this point in the history
  • Loading branch information
gabehamilton committed Jun 30, 2023
1 parent bbf8ccf commit 81aa7ca
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions indexer/queryapi_coordinator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::time::SystemTime;
use cached::SizedCache;
use chrono::{Timelike, Utc};
use futures::stream::{self, StreamExt};
use near_jsonrpc_client::JsonRpcClient;
use tokio::sync::{Mutex, MutexGuard};
Expand Down Expand Up @@ -128,6 +130,13 @@ async fn handle_streamer_message(
context: QueryApiContext<'_>,
indexer_registry: SharedIndexerRegistry,
) -> anyhow::Result<u64> {

let timestamp = context.streamer_message.block.header.timestamp_nanosec;
let now: u64 = Utc::now().timestamp_nanos() as u64;
let difference = now - timestamp;
let ms = difference / 1_000_000;
tracing::info!("Block lag is: {ms}ms");

// build context for enriching filter matches
cache::update_all(&context.streamer_message, context.redis_connection_manager).await?;

Expand Down

0 comments on commit 81aa7ca

Please sign in to comment.