add AccountStorage.is_empty (#29478)
This commit is contained in:
parent
8c878daada
commit
04508ccfa7
|
@ -46,6 +46,13 @@ impl AccountStorage {
|
|||
self.map.iter().map(|iter_item| *iter_item.key()).collect()
|
||||
}
|
||||
|
||||
/// returns true if there are no append vecs for 'slot'
|
||||
pub(crate) fn is_empty(&self, slot: Slot) -> bool {
|
||||
self.get_slot_stores(slot)
|
||||
.map(|storages| storages.read().unwrap().is_empty())
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
/// initialize the storage map to 'all_storages'
|
||||
pub(crate) fn initialize(&mut self, all_storages: AccountStorageMap) {
|
||||
assert!(self.map.is_empty());
|
||||
|
|
|
@ -8861,11 +8861,7 @@ impl AccountsDb {
|
|||
.take(per_pass)
|
||||
.collect::<Vec<_>>();
|
||||
roots_in_this_pass.into_par_iter().for_each(|slot| {
|
||||
let storage_maps = self
|
||||
.storage
|
||||
.get_slot_storage_entries(*slot)
|
||||
.unwrap_or_default();
|
||||
if storage_maps.is_empty() {
|
||||
if self.storage.is_empty(*slot) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14375,7 +14371,7 @@ pub mod tests {
|
|||
db.store_cached((0, &[(&other_account_key, &slot0_account)][..]), None);
|
||||
db.add_root(0);
|
||||
db.flush_accounts_cache(true, None);
|
||||
assert!(!db.storage.get_slot_storage_entries(0).unwrap().is_empty());
|
||||
assert!(!db.storage.is_empty(0));
|
||||
|
||||
// Store into slot 1, a dummy slot that will be dead and purged before flush
|
||||
db.store_cached(
|
||||
|
|
Loading…
Reference in New Issue