diff --git a/src/extensions/api/eth.rs b/src/extensions/api/eth.rs index b3abc35..cc2e0a0 100644 --- a/src/extensions/api/eth.rs +++ b/src/extensions/api/eth.rs @@ -84,12 +84,12 @@ impl EthApi { let client2 = client.clone(); tokio::spawn(async move { let mut interval = tokio::time::interval(stale_timeout); + interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); + let client = client2.clone(); loop { let run = async { - interval.reset(); - // query current head let head = client .request("eth_getBlockByNumber", vec!["latest".into(), true.into()]) @@ -108,6 +108,9 @@ impl EthApi { ) .await?; + // Reset the interval + interval.reset(); + loop { tokio::select! { val = sub.next() => { diff --git a/src/extensions/api/substrate.rs b/src/extensions/api/substrate.rs index 159bf31..77a6391 100644 --- a/src/extensions/api/substrate.rs +++ b/src/extensions/api/substrate.rs @@ -77,12 +77,12 @@ impl SubstrateApi { tokio::spawn(async move { let mut interval = tokio::time::interval(stale_timeout); + interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); let client = client.clone(); loop { let run = async { - interval.reset(); let mut sub = client .subscribe( @@ -92,6 +92,9 @@ impl SubstrateApi { ) .await?; + // Reset the interval + interval.reset(); + loop { tokio::select! { val = sub.next() => {