mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Correctly calculate new distance to initial bucket
This commit is contained in:
parent
12dab0c3ba
commit
a6c7eaec1a
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue