diff --git a/core/src/cluster_slots.rs b/core/src/cluster_slots.rs index 3984f97111..9f6d893866 100644 --- a/core/src/cluster_slots.rs +++ b/core/src/cluster_slots.rs @@ -3,7 +3,7 @@ use { solana_gossip::{ cluster_info::ClusterInfo, contact_info::ContactInfo, crds::Cursor, epoch_slots::EpochSlots, }, - solana_runtime::{bank_forks::BankForks, epoch_stakes::NodeIdToVoteAccounts}, + solana_runtime::{bank::Bank, epoch_stakes::NodeIdToVoteAccounts}, solana_sdk::{clock::Slot, pubkey::Pubkey}, std::{ collections::{BTreeMap, HashMap}, @@ -30,18 +30,13 @@ impl ClusterSlots { self.cluster_slots.read().unwrap().get(&slot).cloned() } - pub(crate) fn update( - &self, - root: Slot, - cluster_info: &ClusterInfo, - bank_forks: &RwLock, - ) { - self.update_peers(bank_forks); + pub(crate) fn update(&self, root_bank: &Bank, cluster_info: &ClusterInfo) { + self.update_peers(root_bank); let epoch_slots = { let mut cursor = self.cursor.lock().unwrap(); cluster_info.get_epoch_slots(&mut cursor) }; - self.update_internal(root, epoch_slots); + self.update_internal(root_bank.slot(), epoch_slots); } fn update_internal(&self, root: Slot, epoch_slots_list: Vec) { @@ -114,8 +109,7 @@ impl ClusterSlots { slot_pubkeys.write().unwrap().insert(node_id, balance); } - fn update_peers(&self, bank_forks: &RwLock) { - let root_bank = bank_forks.read().unwrap().root_bank(); + fn update_peers(&self, root_bank: &Bank) { let root_epoch = root_bank.epoch(); let my_epoch = *self.epoch.read().unwrap(); diff --git a/core/src/cluster_slots_service.rs b/core/src/cluster_slots_service.rs index 09a3042011..251ac39999 100644 --- a/core/src/cluster_slots_service.rs +++ b/core/src/cluster_slots_service.rs @@ -91,7 +91,6 @@ impl ClusterSlotsService { break; } }; - let new_root = bank_forks.read().unwrap().root(); let mut lowest_slot_elapsed = Measure::start("lowest_slot_elapsed"); let lowest_slot = blockstore.lowest_slot(); Self::update_lowest_slot(lowest_slot, &cluster_info); @@ -105,7 +104,8 @@ impl ClusterSlotsService { &cluster_info, ); } - cluster_slots.update(new_root, &cluster_info, &bank_forks); + let root_bank = bank_forks.read().unwrap().root_bank(); + cluster_slots.update(&root_bank, &cluster_info); process_cluster_slots_updates_elapsed.stop(); cluster_slots_service_timing.update(