mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(bin): skip first ConsensusLayerHealthEvents tick (#3012)
This commit is contained in:
@ -7,7 +7,7 @@ use std::{
|
|||||||
task::{ready, Context, Poll},
|
task::{ready, Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tokio::time::Interval;
|
use tokio::time::{Instant, Interval};
|
||||||
|
|
||||||
/// Interval of checking Consensus Layer client health.
|
/// Interval of checking Consensus Layer client health.
|
||||||
const CHECK_INTERVAL: Duration = Duration::from_secs(300);
|
const CHECK_INTERVAL: Duration = Duration::from_secs(300);
|
||||||
@ -27,7 +27,9 @@ pub struct ConsensusLayerHealthEvents {
|
|||||||
impl ConsensusLayerHealthEvents {
|
impl ConsensusLayerHealthEvents {
|
||||||
/// Creates a new [ConsensusLayerHealthEvents] with the given canonical chain tracker.
|
/// Creates a new [ConsensusLayerHealthEvents] with the given canonical chain tracker.
|
||||||
pub fn new(canon_chain: Box<dyn CanonChainTracker>) -> Self {
|
pub fn new(canon_chain: Box<dyn CanonChainTracker>) -> Self {
|
||||||
Self { interval: tokio::time::interval(CHECK_INTERVAL), canon_chain }
|
// Skip the first tick to prevent the false `ConsensusLayerHealthEvent::NeverSeen` event.
|
||||||
|
let interval = tokio::time::interval_at(Instant::now() + CHECK_INTERVAL, CHECK_INTERVAL);
|
||||||
|
Self { interval, canon_chain }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user