From 45348b2c83c5607bf4cccf41a14b7aa37fc02ce1 Mon Sep 17 00:00:00 2001 From: sakridge Date: Wed, 25 Mar 2020 10:21:30 -0700 Subject: [PATCH] Remove accounts unwrap (#9062) automerge --- runtime/src/accounts_db.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index cd1e1bff78..80f6e0462d 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1464,8 +1464,10 @@ impl AccountsDB { let storage = self.storage.read().unwrap(); let mut stores: Vec> = vec![]; for slot in dead_slots.iter() { - for store in storage.0.get(slot).unwrap().values() { - stores.push(store.clone()); + if let Some(slot_storage) = storage.0.get(slot) { + for store in slot_storage.values() { + stores.push(store.clone()); + } } } drop(storage); @@ -3486,4 +3488,12 @@ pub mod tests { assert_load_account(&accounts, current_slot, pubkey2, old_lamport); assert_load_account(&accounts, current_slot, dummy_pubkey, dummy_lamport); } + + #[test] + fn clean_dead_slots_empty() { + let accounts = AccountsDB::new_single(); + let mut dead_slots = HashSet::new(); + dead_slots.insert(10); + accounts.clean_dead_slots(&dead_slots); + } }