diff --git a/Cargo.lock b/Cargo.lock index 5919086038..dc2351bf12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5867,9 +5867,9 @@ dependencies = [ [[package]] name = "tentacle" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457c5771b5b59538fb07d70d5db3d6b9f94f45e5c1ea1197165aa050f2de4f4d" +checksum = "6218c3269605008b5e88f4e91fa2e98e20491213c464dc6da8370858db89d92b" dependencies = [ "async-trait", "bytes", diff --git a/network/src/services/dump_peer_store.rs b/network/src/services/dump_peer_store.rs index 775ea7a2a5..f95230a79f 100644 --- a/network/src/services/dump_peer_store.rs +++ b/network/src/services/dump_peer_store.rs @@ -13,9 +13,6 @@ const DEFAULT_DUMP_INTERVAL: Duration = Duration::from_secs(3600); // 1 hour /// Save current peer store data regularly pub struct DumpPeerStoreService { network_state: Arc, - #[cfg(not(target_family = "wasm"))] - interval: Option, - #[cfg(target_family = "wasm")] interval: Option, } @@ -57,32 +54,12 @@ impl Drop for DumpPeerStoreService { impl Future for DumpPeerStoreService { type Output = (); - #[cfg(not(target_family = "wasm"))] - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - if self.interval.is_none() { - self.interval = { - let mut interval = tokio::time::interval_at( - tokio::time::Instant::now() + DEFAULT_DUMP_INTERVAL, - DEFAULT_DUMP_INTERVAL, - ); - // The dump peer store service does not need to urgently compensate for the missed wake, - // just delay behavior is enough - interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); - Some(interval) - } - } - while self.interval.as_mut().unwrap().poll_tick(cx).is_ready() { - self.dump_peer_store() - } - Poll::Pending - } - - #[cfg(target_family = "wasm")] fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { use futures::StreamExt; if self.interval.is_none() { self.interval = { - let mut interval = p2p::runtime::Interval::new(DEFAULT_DUMP_INTERVAL); + let mut interval = + p2p::runtime::Interval::new_at(DEFAULT_DUMP_INTERVAL, DEFAULT_DUMP_INTERVAL); // The outbound service does not need to urgently compensate for the missed wake, // just skip behavior is enough interval.set_missed_tick_behavior(p2p::runtime::MissedTickBehavior::Skip); diff --git a/network/src/services/outbound_peer.rs b/network/src/services/outbound_peer.rs index 10dca1c33c..5a59d76684 100644 --- a/network/src/services/outbound_peer.rs +++ b/network/src/services/outbound_peer.rs @@ -155,7 +155,8 @@ impl Future for OutboundPeerService { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if self.interval.is_none() { self.interval = { - let mut interval = Interval::new(self.try_connect_interval); + let mut interval = + Interval::new_at(self.try_connect_interval, self.try_connect_interval); // The outbound service does not need to urgently compensate for the missed wake, // just skip behavior is enough interval.set_missed_tick_behavior(MissedTickBehavior::Skip); diff --git a/network/src/services/protocol_type_checker.rs b/network/src/services/protocol_type_checker.rs index c41ba14147..a4f371ce84 100644 --- a/network/src/services/protocol_type_checker.rs +++ b/network/src/services/protocol_type_checker.rs @@ -129,7 +129,7 @@ impl Future for ProtocolTypeCheckerService { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if self.interval.is_none() { self.interval = { - let mut interval = Interval::new(CHECK_INTERVAL); + let mut interval = Interval::new_at(CHECK_INTERVAL, CHECK_INTERVAL); // The protocol type checker service does not need to urgently compensate for the missed wake, // just skip behavior is enough interval.set_missed_tick_behavior(MissedTickBehavior::Skip);