Remove accounts unwrap (#9062)

automerge
This commit is contained in:
sakridge 2020-03-25 10:21:30 -07:00 committed by GitHub
parent c558db2a48
commit 45348b2c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -1464,8 +1464,10 @@ impl AccountsDB {
let storage = self.storage.read().unwrap();
let mut stores: Vec<Arc<AccountStorageEntry>> = 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);
}
}