Correctly calculate new distance to initial bucket

This commit is contained in:
Gwilym Kuiper 2022-03-18 01:06:07 +00:00
parent 12dab0c3ba
commit a6c7eaec1a

View file

@ -75,10 +75,6 @@ impl<K, V> NodeStorage<K, V> {
if let Some(current_node) = current_node {
if current_node.distance_to_initial_bucket <= new_node.distance_to_initial_bucket {
max_distance_to_initial_bucket = new_node
.distance_to_initial_bucket
.max(max_distance_to_initial_bucket);
mem::swap(&mut new_node, current_node);
}
} else {
@ -87,6 +83,9 @@ impl<K, V> NodeStorage<K, V> {
}
new_node.distance_to_initial_bucket += 1;
max_distance_to_initial_bucket = new_node
.distance_to_initial_bucket
.max(max_distance_to_initial_bucket);
}
max_distance_to_initial_bucket