Skip to content

Commit

Permalink
fix(networking): increase the responsible range of nodes to K_VALUE/2…
Browse files Browse the repository at this point in the history
… peers away
  • Loading branch information
joshuef committed Apr 5, 2024
1 parent 131efe1 commit 7e99524
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use crate::metrics::NetworkMetrics;
#[cfg(feature = "open-metrics")]
use crate::metrics_service::run_metrics_server;
use crate::NodeIssue;
use crate::{
bootstrap::{ContinuousBootstrap, BOOTSTRAP_INTERVAL},
circular_vec::CircularVec,
Expand All @@ -26,7 +27,6 @@ use crate::{
target_arch::{interval, spawn, Instant},
transport, Network, CLOSE_GROUP_SIZE,
};
use crate::{NodeIssue, REPLICATE_RANGE};
use futures::StreamExt;
use libp2p::kad::KBucketDistance as Distance;
#[cfg(feature = "local-discovery")]
Expand Down Expand Up @@ -634,11 +634,11 @@ impl SwarmDriver {

let our_address = NetworkAddress::from_peer(self.self_peer_id);

// get REPLICATE_RANGE + 2 peer's address distance
// get K_VALUE/2 peer's address distance
// This is a rough estimate of the farthest address we might be responsible for.
// We want this to be higher than actually necessary, so we retain more data
// and can be sure to pass bad node checks
if let Some(peer) = closest_k_peers.get(REPLICATE_RANGE + 2) {
if let Some(peer) = closest_k_peers.get(K_VALUE.get() / 2) {
let address = NetworkAddress::from_peer(*peer);
let distance = our_address.distance(&address);
farthest_distance = Some(distance);
Expand Down

0 comments on commit 7e99524

Please sign in to comment.