Skip to content

Commit

Permalink
chore: debug dump peerstore
Browse files Browse the repository at this point in the history
  • Loading branch information
quake committed Nov 19, 2024
1 parent 18d0d94 commit f50dd3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions network/src/peer_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl PeerRegistry {
session_type: SessionType,
peer_store: &mut PeerStore,
) -> Result<Option<Peer>, Error> {
debug!("start accept peer {:?}", session_id);
if self.peers.contains_key(&session_id) {
return Err(PeerError::SessionExists(session_id).into());
}
Expand Down Expand Up @@ -112,6 +113,7 @@ impl PeerRegistry {
peer_store.add_connected_peer(remote_addr.clone(), session_type);
let peer = Peer::new(session_id, session_type, remote_addr, is_whitelist);
self.peers.insert(session_id, peer);
debug!("end accept peer {:?}", session_id);
Ok(evicted_peer)
}

Expand Down
7 changes: 2 additions & 5 deletions network/src/services/dump_peer_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
task::{Context, Poll},
time::Duration,
};
use tokio::time::{Instant, Interval, MissedTickBehavior};
use tokio::time::{Interval, MissedTickBehavior};

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

Expand Down Expand Up @@ -50,10 +50,7 @@ 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 = tokio::time::interval_at(
Instant::now() + DEFAULT_DUMP_INTERVAL,
DEFAULT_DUMP_INTERVAL,
);
let mut interval = tokio::time::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);
Expand Down

0 comments on commit f50dd3a

Please sign in to comment.