From fed90cfbe85972e6f0b14436f8a24e51252ad2ab Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 17:41:59 +0000 Subject: [PATCH] Fix accounts index panic in purge_exact (#17757) (#17935) (cherry picked from commit c2191d885dc9689088c0dedcb30433a51a01bf12) Co-authored-by: sakridge --- runtime/src/accounts_index.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 98f66d9572..144ee5e6bf 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1088,19 +1088,22 @@ impl AccountsIndex { where C: Contains<'a, Slot>, { - let mut write_account_map_entry = self.get_account_write_entry(pubkey).unwrap(); - write_account_map_entry.slot_list_mut(|slot_list| { - slot_list.retain(|(slot, item)| { - let should_purge = slots_to_purge.contains(&slot); - if should_purge { - reclaims.push((*slot, item.clone())); - false - } else { - true - } - }); - slot_list.is_empty() - }) + if let Some(mut write_account_map_entry) = self.get_account_write_entry(pubkey) { + write_account_map_entry.slot_list_mut(|slot_list| { + slot_list.retain(|(slot, item)| { + let should_purge = slots_to_purge.contains(&slot); + if should_purge { + reclaims.push((*slot, item.clone())); + false + } else { + true + } + }); + slot_list.is_empty() + }) + } else { + true + } } pub fn min_ongoing_scan_root(&self) -> Option {