From 123e0bdba7676e8de70f684d9a7d4953fbd04e2b Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Wed, 21 Apr 2021 20:38:48 -0500 Subject: [PATCH] don't iterate slot_list if zero-lamport (#16678) --- runtime/src/accounts_db.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 962568df98..bbb68983d0 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1570,16 +1570,16 @@ impl AccountsDb { self.accounts_index .roots_and_ref_count(&locked_entry, max_clean_root), ); - } - - // prune zero_lamport_pubkey set which should contain all 0-lamport - // keys whether rooted or not. A 0-lamport update may become rooted - // in the future. - let has_zero_lamport_accounts = slot_list - .iter() - .any(|(_slot, account_info)| account_info.lamports == 0); - if !has_zero_lamport_accounts { - self.accounts_index.remove_zero_lamport_key(pubkey); + } else { + // prune zero_lamport_pubkey set which should contain all 0-lamport + // keys whether rooted or not. A 0-lamport update may become rooted + // in the future. + let has_zero_lamport_accounts = slot_list + .iter() + .any(|(_slot, account_info)| account_info.lamports == 0); + if !has_zero_lamport_accounts { + self.accounts_index.remove_zero_lamport_key(pubkey); + } } // Release the lock