Skip to content

Commit

Permalink
fix peers counting in routing table
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-frb committed Jul 3, 2024
1 parent ee674a7 commit 0ae16d1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
mod test;

use crate::addresses::Addresses;
use crate::bootstrap;
use crate::handler::{Handler, HandlerEvent, HandlerIn, RequestId};
use crate::kbucket::{self, Distance, KBucketsTable, NodeStatus};
use crate::protocol::{ConnectionType, KadPeer, ProtocolConfig};
Expand All @@ -33,6 +32,7 @@ use crate::record::{
store::{self, RecordStore},
ProviderRecord, Record,
};
use crate::{bootstrap, K_VALUE};
use crate::{jobs::*, protocol};
use fnv::FnvHashSet;
use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr};
Expand Down Expand Up @@ -1381,7 +1381,12 @@ where
/// table is currently small (less that `K_VALUE` peers are present) and only
/// trigger a bootstrap in that case
fn bootstrap_on_low_peers(&mut self) {
if self.kbuckets().count() < K_VALUE.get() {
if self
.kbuckets()
.map(|kbucket| kbucket.num_entries())
.sum::<usize>()
< K_VALUE.get()
{
self.bootstrap_status.trigger();
}
}
Expand Down

0 comments on commit 0ae16d1

Please sign in to comment.