Skip to content

Commit

Permalink
fix(node): wider range to replicate out
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Jan 22, 2025
1 parent f2bb64a commit cae2e65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ant-networking/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ impl SwarmDriver {
) -> Result<Vec<PeerId>> {
let is_periodic_replicate = target.as_peer_id().is_some();
let expected_candidates = if is_periodic_replicate {
CLOSE_GROUP_SIZE + 4
CLOSE_GROUP_SIZE * 2
} else {
CLOSE_GROUP_SIZE
};
Expand Down
9 changes: 6 additions & 3 deletions ant-networking/src/replication_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,19 @@ impl ReplicationFetcher {
"Distance to target {addr:?} is {distance:?}, against range {distance_range:?}"
);
let mut is_in_range = distance <= *distance_range;
if !is_in_range {
// For middle-range records, they could be farther than distance_range,
// but still supposed to be held by the closest group to us.
if !is_in_range && distance - *distance_range < *distance_range {
closest_k_peers.sort_by_key(|key| key.distance(addr));
let closest_group: HashSet<_> = closest_k_peers.iter().take(CLOSE_GROUP_SIZE).collect();
if closest_group.contains(&self_address) {
debug!("Record {addr:?} has a far distance but still among {CLOSE_GROUP_SIZE} closest within {} neighbourd.", closest_k_peers.len());
is_in_range = true;
} else {
out_of_range_keys.push(addr.clone());
}
}
if !is_in_range {
out_of_range_keys.push(addr.clone());
}
is_in_range
});
}
Expand Down

0 comments on commit cae2e65

Please sign in to comment.