Skip to content

Commit

Permalink
cluster-info: Get rid of some integer math while we're here
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson authored and mergify[bot] committed Apr 6, 2021
1 parent b6b0870 commit b71875d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,9 @@ impl ClusterInfo {

pub fn contact_info_trace(&self) -> String {
let now = timestamp();
let mut shred_spy_nodes = 0;
let mut total_spy_nodes = 0;
let mut different_shred_nodes = 0;
let mut shred_spy_nodes = 0usize;
let mut total_spy_nodes = 0usize;
let mut different_shred_nodes = 0usize;
let my_pubkey = self.id();
let my_shred_version = self.my_shred_version();
let nodes: Vec<_> = self
Expand All @@ -918,16 +918,16 @@ impl ClusterInfo {
.filter_map(|(node, last_updated)| {
let is_spy_node = Self::is_spy_node(&node);
if is_spy_node {
total_spy_nodes += 1;
total_spy_nodes = total_spy_nodes.saturating_add(1);
}

let node_version = self.get_node_version(&node.id);
if my_shred_version != 0 && (node.shred_version != 0 && node.shred_version != my_shred_version) {
different_shred_nodes += 1;
different_shred_nodes = different_shred_nodes.saturating_add(1);
None
} else {
if is_spy_node {
shred_spy_nodes += 1;
shred_spy_nodes = shred_spy_nodes.saturating_add(1);
}
fn addr_to_string(default_ip: &IpAddr, addr: &SocketAddr) -> String {
if ContactInfo::is_valid_address(addr) {
Expand Down Expand Up @@ -977,7 +977,7 @@ impl ClusterInfo {
{}\
Nodes: {}{}{}",
nodes.join(""),
nodes.len() - shred_spy_nodes,
nodes.len().saturating_sub(shred_spy_nodes),
if total_spy_nodes > 0 {
format!("\nSpies: {}", total_spy_nodes)
} else {
Expand Down

0 comments on commit b71875d

Please sign in to comment.