diff --git a/runtime/src/account_storage.rs b/runtime/src/account_storage.rs index b421060f65cfbf..33a9ac252f1670 100644 --- a/runtime/src/account_storage.rs +++ b/runtime/src/account_storage.rs @@ -5,7 +5,7 @@ use { dashmap::DashMap, solana_sdk::clock::Slot, std::{ - collections::{hash_map::RandomState, HashMap}, + collections::HashMap, sync::{Arc, RwLock}, }, }; @@ -65,14 +65,6 @@ impl AccountStorage { self.map.iter() } - pub(crate) fn get( - &self, - slot: &Slot, - ) -> Option> { - self.map.get(slot) - } - - /// insert 'store' into 'map' at 'slot' pub(crate) fn insert(&self, slot: Slot, store: Arc) { let slot_storages: SlotStores = self.get_slot_stores(slot).unwrap_or_else(|| // DashMap entry.or_insert() returns a RefMut, essentially a write lock, diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index f46116a87d52c7..f2f830ac252f9b 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -8533,8 +8533,12 @@ impl AccountsDb { let slots = self .storage .iter() - .map(|k| *k.key() as Slot) - .filter(|slot| requested_slots.contains(slot)) + .filter_map(|entry| { + let slot = *entry.key() as Slot; + requested_slots + .contains(&slot) + .then_some((slot, Arc::clone(entry.value()))) + }) .collect::>(); m.stop(); let mut m2 = Measure::start("filter"); @@ -8546,29 +8550,24 @@ impl AccountsDb { .map(|slots| { slots .iter() - .filter_map(|slot| { + .filter_map(|(slot, storages)| { if self.accounts_index.is_alive_root(*slot) || ancestors .map(|ancestors| ancestors.contains_key(slot)) .unwrap_or_default() { - self.storage.get(slot).map_or_else( - || None, - |item| { - let storages = item - .read() - .unwrap() - .values() - .filter(|x| x.has_accounts()) - .cloned() - .collect::>(); - if !storages.is_empty() { - Some((storages, *slot)) - } else { - None - } - }, - ) + let storages = storages + .read() + .unwrap() + .values() + .filter(|x| x.has_accounts()) + .cloned() + .collect::>(); + if !storages.is_empty() { + Some((storages, *slot)) + } else { + None + } } else { None }