diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index fc6bda42a4..6c0efad5ba 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -1800,7 +1800,7 @@ impl ClusterInfo { .unwrap() } - fn handle_batch_prune_messages(&self, messages: Vec<(Pubkey, PruneData)>) { + fn handle_batch_prune_messages(&self, messages: Vec) { let _st = ScopedTimer::from(&self.stats.handle_batch_prune_messages_time); if messages.is_empty() { return; @@ -1808,22 +1808,19 @@ impl ClusterInfo { self.stats .prune_message_count .add_relaxed(messages.len() as u64); - self.stats.prune_message_len.add_relaxed( - messages - .iter() - .map(|(_, data)| data.prunes.len() as u64) - .sum(), - ); + self.stats + .prune_message_len + .add_relaxed(messages.iter().map(|data| data.prunes.len() as u64).sum()); let mut prune_message_timeout = 0; let mut bad_prune_destination = 0; let self_pubkey = self.id(); { let _st = ScopedTimer::from(&self.stats.process_prune); let now = timestamp(); - for (from, data) in messages { + for data in messages { match self.gossip.process_prune_msg( &self_pubkey, - &from, + &data.pubkey, &data.destination, &data.prunes, data.wallclock, @@ -2423,7 +2420,7 @@ impl ClusterInfo { check_duplicate_instance(&data)?; push_messages.push((from, data)); } - Protocol::PruneMessage(from, data) => prune_messages.push((from, data)), + Protocol::PruneMessage(_from, data) => prune_messages.push(data), Protocol::PingMessage(ping) => ping_messages.push((from_addr, ping)), Protocol::PongMessage(pong) => pong_messages.push((from_addr, pong)), } diff --git a/gossip/src/crds_gossip.rs b/gossip/src/crds_gossip.rs index a5f01e7253..34d867e38b 100644 --- a/gossip/src/crds_gossip.rs +++ b/gossip/src/crds_gossip.rs @@ -157,11 +157,9 @@ impl CrdsGossip { wallclock: u64, now: u64, ) -> Result<(), CrdsGossipError> { - let expired = now > wallclock + self.push.prune_timeout; - if expired { - return Err(CrdsGossipError::PruneMessageTimeout); - } - if self_pubkey == destination { + if now > wallclock.saturating_add(self.push.prune_timeout) { + Err(CrdsGossipError::PruneMessageTimeout) + } else if self_pubkey == destination { self.push.process_prune_msg(self_pubkey, peer, origin); Ok(()) } else { diff --git a/gossip/src/crds_gossip_push.rs b/gossip/src/crds_gossip_push.rs index 28ccb0661c..d98489363c 100644 --- a/gossip/src/crds_gossip_push.rs +++ b/gossip/src/crds_gossip_push.rs @@ -242,7 +242,12 @@ impl CrdsGossipPush { } /// Add the `from` to the peer's filter of nodes. - pub fn process_prune_msg(&self, self_pubkey: &Pubkey, peer: &Pubkey, origins: &[Pubkey]) { + pub(crate) fn process_prune_msg( + &self, + self_pubkey: &Pubkey, + peer: &Pubkey, + origins: &[Pubkey], + ) { if let Some(filter) = self.active_set.read().unwrap().get(peer) { for origin in origins { if origin != self_pubkey {