chore: shorten info interval (#4666)

This commit is contained in:
Matthias Seitz
2023-09-20 08:56:48 +02:00
committed by GitHub
parent a979f5b661
commit 0fbc3f6c94

View File

@ -21,7 +21,7 @@ use tokio::time::Interval;
use tracing::{info, warn}; use tracing::{info, warn};
/// Interval of reporting node state. /// Interval of reporting node state.
const INFO_MESSAGE_INTERVAL: Duration = Duration::from_secs(30); const INFO_MESSAGE_INTERVAL: Duration = Duration::from_secs(25);
/// The current high-level state of the node. /// The current high-level state of the node.
struct NodeState { struct NodeState {
@ -199,7 +199,8 @@ pub async fn handle_events<E>(
{ {
let state = NodeState::new(network, latest_block_number); let state = NodeState::new(network, latest_block_number);
let mut info_interval = tokio::time::interval(INFO_MESSAGE_INTERVAL); let start = tokio::time::Instant::now() + Duration::from_secs(3);
let mut info_interval = tokio::time::interval_at(start, INFO_MESSAGE_INTERVAL);
info_interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); info_interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
let handler = EventHandler { state, events, info_interval }; let handler = EventHandler { state, events, info_interval };