From 71efac46cba9e2cd300b7f1cdb566bffe2fb17c7 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 29 Jun 2021 09:17:05 -0700 Subject: [PATCH] Hoist keypair() out of some loops --- gossip/src/cluster_info.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 46f3fb3f26..a545bf095f 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -955,6 +955,7 @@ impl ClusterInfo { None => 0, }; let mut entries = Vec::default(); + let keypair = self.keypair(); while !update.is_empty() { let ix = (epoch_slot_index % crds_value::MAX_EPOCH_SLOTS) as u8; let now = timestamp(); @@ -967,7 +968,7 @@ impl ClusterInfo { update = &update[n..]; if n > 0 { let epoch_slots = CrdsData::EpochSlots(ix, slots); - let entry = CrdsValue::new_signed(epoch_slots, &self.keypair()); + let entry = CrdsValue::new_signed(epoch_slots, &keypair); entries.push(entry); } epoch_slot_index += 1; @@ -2286,10 +2287,11 @@ impl ClusterInfo { where I: IntoIterator, { + let keypair = self.keypair(); let packets: Vec<_> = pings .into_iter() .filter_map(|(addr, ping)| { - let pong = Pong::new(&ping, &self.keypair()).ok()?; + let pong = Pong::new(&ping, &keypair).ok()?; let pong = Protocol::PongMessage(pong); match Packet::from_data(Some(&addr), pong) { Ok(packet) => Some(packet),