From 245080efd3d28ca9694addab3a97d8d092f8b388 Mon Sep 17 00:00:00 2001 From: Ashwin Sekar Date: Thu, 3 Oct 2024 19:47:33 +0000 Subject: [PATCH] pr feedback: rename missed pubkey -> vote_pubkey --- core/src/banking_stage/latest_unprocessed_votes.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/banking_stage/latest_unprocessed_votes.rs b/core/src/banking_stage/latest_unprocessed_votes.rs index 71eca8cdf19646..114c6ebf17eb05 100644 --- a/core/src/banking_stage/latest_unprocessed_votes.rs +++ b/core/src/banking_stage/latest_unprocessed_votes.rs @@ -345,8 +345,8 @@ impl LatestUnprocessedVotes { fn weighted_random_order_by_stake(&self) -> impl Iterator { // Efraimidis and Spirakis algo for weighted random sample without replacement let epoch_stakes = self.cached_epoch_stakes.read().unwrap(); - let latest_votes_per_pubkey = self.latest_vote_per_vote_pubkey.read().unwrap(); - let mut pubkey_with_weight: Vec<(f64, Pubkey)> = latest_votes_per_pubkey + let latest_vote_per_vote_pubkey = self.latest_vote_per_vote_pubkey.read().unwrap(); + let mut pubkey_with_weight: Vec<(f64, Pubkey)> = latest_vote_per_vote_pubkey .keys() .filter_map(|&pubkey| { let stake = epoch_stakes.vote_account_stake(&pubkey); @@ -380,9 +380,9 @@ impl LatestUnprocessedVotes { // Evict any now unstaked pubkeys let epoch_stakes = self.cached_epoch_stakes.read().unwrap(); - let mut latest_votes_per_pubkey = self.latest_vote_per_vote_pubkey.write().unwrap(); + let mut latest_vote_per_vote_pubkey = self.latest_vote_per_vote_pubkey.write().unwrap(); let mut unstaked_votes = 0; - latest_votes_per_pubkey.retain(|vote_pubkey, vote| { + latest_vote_per_vote_pubkey.retain(|vote_pubkey, vote| { let is_present = !vote.read().unwrap().is_vote_taken(); let should_evict = epoch_stakes.vote_account_stake(vote_pubkey) == 0; if is_present && should_evict { @@ -943,11 +943,11 @@ mod tests { .update_latest_vote(vote, false /* should replenish */); if i % 214 == 0 { // Simulate draining and processing packets - let latest_votes_per_pubkey = latest_unprocessed_votes_tpu + let latest_vote_per_vote_pubkey = latest_unprocessed_votes_tpu .latest_vote_per_vote_pubkey .read() .unwrap(); - latest_votes_per_pubkey.iter().for_each(|(_pubkey, lock)| { + latest_vote_per_vote_pubkey.iter().for_each(|(_pubkey, lock)| { let mut latest_vote = lock.write().unwrap(); if !latest_vote.is_vote_taken() { latest_vote.take_vote();