Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Oct 25, 2024
1 parent df002c7 commit 500aed5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions network/src/services/dump_peer_store.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::NetworkState;
use ckb_logger::{debug, warn};
use futures::{Future, StreamExt};
use p2p::runtime::{Interval, MissedTickBehavior};
use futures::Future;
use std::{
pin::Pin,
sync::Arc,
task::{Context, Poll},
time::Duration,
};
use tokio::time::{Instant, Interval, MissedTickBehavior};

const DEFAULT_DUMP_INTERVAL: Duration = Duration::from_secs(3600); // 1 hour

Expand Down Expand Up @@ -51,20 +51,17 @@ impl Future for DumpPeerStoreService {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if self.interval.is_none() {
self.interval = {
let mut interval = Interval::new(DEFAULT_DUMP_INTERVAL);
let mut interval = tokio::time::interval_at(
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(MissedTickBehavior::Delay);
Some(interval)
}
}
while self
.interval
.as_mut()
.unwrap()
.poll_next_unpin(cx)
.is_ready()
{
while self.interval.as_mut().unwrap().poll_tick(cx).is_ready() {
self.dump_peer_store()
}
Poll::Pending
Expand Down

0 comments on commit 500aed5

Please sign in to comment.