Skip to content

Commit

Permalink
Removing unhelpful comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Feb 23, 2024
1 parent b541a85 commit a703bb0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions chitchat/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl Ord for Staleness {
// Unknown nodes get gossiped first.
self.is_unknown.cmp(&other.is_unknown).then_with(|| {
// Then nodes with the highest number of stale records get higher priority.
self.num_stale_records.cmp(&other.num_stale_records)
self.num_stale_key_values.cmp(&other.num_stale_key_values)
})
}
}
Expand Down Expand Up @@ -451,19 +451,17 @@ struct SortedStaleNodes<'a> {
/// the node is not a candidate for gossip.
fn staleness_score(node_state: &NodeState, floor_version: u64) -> Option<Staleness> {
let is_unknown = floor_version == 0u64;
let num_stale_kv = if is_unknown {
let num_stale_key_values = if is_unknown {
node_state.num_key_values()
} else {
node_state.stale_key_values(floor_version).count()
};
// We don't return None if the node is unknown yet because we want to make
// sure the node is added to the neighbors's list.
if !is_unknown && num_stale_kv == 0 {
if !is_unknown && num_stale_key_values == 0 {
return None;
}
Some(Staleness {
is_unknown,
num_stale_records: num_stale_kv,
num_stale_key_values,
})
}

Expand Down Expand Up @@ -664,7 +662,7 @@ mod tests {
stale_nodes.insert(&node2, &node2_state);
let expected_staleness = Staleness {
is_unknown: true,
num_stale_records: 1,
num_stale_key_values: 1,
};
assert_eq!(stale_nodes.stale_nodes[&expected_staleness].len(), 1);

Expand All @@ -679,7 +677,7 @@ mod tests {
stale_nodes.insert(&node3, &node3_state);
let expected_staleness = Staleness {
is_unknown: true,
num_stale_records: 2,
num_stale_key_values: 2,
};
assert_eq!(stale_nodes.stale_nodes[&expected_staleness].len(), 1);
}
Expand Down Expand Up @@ -718,7 +716,7 @@ mod tests {
assert_eq!(stale_nodes.stale_nodes.len(), 1);
let expected_staleness = Staleness {
is_unknown: false,
num_stale_records: 2,
num_stale_key_values: 2,
};
assert_eq!(stale_nodes.stale_nodes[&expected_staleness].len(), 1);
}
Expand Down

0 comments on commit a703bb0

Please sign in to comment.