Skip to content

Commit

Permalink
protocols/kad/query/disjoint: Log number finished on finish_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Jun 15, 2020
1 parent 5b76eda commit b69f24f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions protocols/kad/src/query/peers/closest/disjoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use super::*;
use crate::kbucket::{Key, KeyBytes};
use libp2p_core::PeerId;
use log::debug;
use std::{
collections::HashMap,
iter::{Cycle, Map, Peekable},
Expand Down Expand Up @@ -276,11 +277,19 @@ impl ClosestDisjointPeersIter {
where
I: IntoIterator<Item = PeerId>
{
let mut count = 0;

for peer in peers {
count += 1;
if let Some(PeerState{ initiated_by, .. }) = self.contacted_peers.get_mut(&peer) {
self.iters[*initiated_by].finish();
}
}

debug!("Finished {} out of {} paths.", count, self.iters.len());
if self.is_finished() {
debug!("All paths finished.");
}
}

/// Immediately transitions the iterator to [`PeersIterState::Finished`].
Expand Down

0 comments on commit b69f24f

Please sign in to comment.