diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 6e15b5dc57..0b58a902eb 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -4487,7 +4487,7 @@ impl AccountsDb { ); } - self.handle_dropped_roots_for_ancient(dropped_roots); + self.handle_dropped_roots_for_ancient(dropped_roots.into_iter()); total.stop(); self.shrink_ancient_stats @@ -4601,16 +4601,17 @@ impl AccountsDb { /// each slot in 'dropped_roots' has been combined into an ancient append vec. /// We are done with the slot now forever. - pub(crate) fn handle_dropped_roots_for_ancient(&self, dropped_roots: Vec) { - if !dropped_roots.is_empty() { - dropped_roots.iter().for_each(|slot| { - self.accounts_index - .clean_dead_slot(*slot, &mut AccountsIndexRootsStats::default()); - self.remove_bank_hash_info(slot); - // the storage has been removed from this slot and recycled or dropped - assert!(self.storage.remove(slot).is_none()); - }); - } + pub(crate) fn handle_dropped_roots_for_ancient( + &self, + dropped_roots: impl Iterator, + ) { + dropped_roots.for_each(|slot| { + self.accounts_index + .clean_dead_slot(slot, &mut AccountsIndexRootsStats::default()); + self.remove_bank_hash_info(&slot); + // the storage has been removed from this slot and recycled or dropped + assert!(self.storage.remove(&slot).is_none()); + }); } /// add all 'pubkeys' into the set of pubkeys that are 'uncleaned', associated with 'slot' @@ -17432,7 +17433,7 @@ pub mod tests { assert!(db.storage.is_empty_entry(next_slot)); // this removes the storages entry completely from the hashmap for 'next_slot'. // Otherwise, we have a zero length vec in that hashmap - db.handle_dropped_roots_for_ancient(dropped_roots); + db.handle_dropped_roots_for_ancient(dropped_roots.into_iter()); assert!(db.storage.get_slot_storage_entry(next_slot).is_none()); // include all the slots we put into the ancient append vec - they should contain nothing @@ -17682,7 +17683,7 @@ pub mod tests { fn test_handle_dropped_roots_for_ancient() { solana_logger::setup(); let db = AccountsDb::new_single_for_tests(); - db.handle_dropped_roots_for_ancient(Vec::default()); + db.handle_dropped_roots_for_ancient(std::iter::empty::()); let slot0 = 0; let dropped_roots = vec![slot0]; assert!(db.get_bank_hash_stats(slot0).is_some()); @@ -17690,7 +17691,7 @@ pub mod tests { db.accounts_index.add_uncleaned_roots([slot0].into_iter()); assert!(db.accounts_index.is_uncleaned_root(slot0)); assert!(db.accounts_index.is_alive_root(slot0)); - db.handle_dropped_roots_for_ancient(dropped_roots); + db.handle_dropped_roots_for_ancient(dropped_roots.into_iter()); assert!(db.get_bank_hash_stats(slot0).is_none()); assert!(!db.accounts_index.is_uncleaned_root(slot0)); assert!(!db.accounts_index.is_alive_root(slot0)); @@ -17701,7 +17702,7 @@ pub mod tests { } #[test] - #[should_panic(expected = "assertion failed: self.storage.remove(slot).is_none()")] + #[should_panic(expected = "assertion failed: self.storage.remove")] fn test_handle_dropped_roots_for_ancient_assert() { solana_logger::setup(); let common_store_path = Path::new(""); @@ -17716,7 +17717,7 @@ pub mod tests { let slot0 = 0; let dropped_roots = vec![slot0]; insert_store(&db, entry); - db.handle_dropped_roots_for_ancient(dropped_roots); + db.handle_dropped_roots_for_ancient(dropped_roots.into_iter()); } #[test]