load_accounts_index_for_shrink uses &item instead of (&item.0, &item.1) (#26266)

This commit is contained in:
Jeff Washington (jwash) 2022-06-27 22:40:45 -05:00 committed by GitHub
parent 31d870fe1b
commit e164879f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -2997,7 +2997,7 @@ impl AccountsDb {
fn load_accounts_index_for_shrink<'a, I>(
&'a self,
iter: I,
alive_accounts: &mut Vec<(&'a Pubkey, &'a FoundStoredAccount<'a>)>,
alive_accounts: &mut Vec<&'a (Pubkey, FoundStoredAccount<'a>)>,
mut unrefed_pubkeys: Option<&mut Vec<&'a Pubkey>>,
) -> usize
where
@ -3007,7 +3007,9 @@ impl AccountsDb {
let mut alive = 0;
let mut dead = 0;
iter.for_each(|(pubkey, stored_account)| {
iter.for_each(|pair| {
let pubkey = &pair.0;
let stored_account = &pair.1;
let lookup = self.accounts_index.get_account_read_entry(pubkey);
if let Some(locked_entry) = lookup {
let is_alive = locked_entry.slot_list().iter().any(|(_slot, acct_info)| {
@ -3027,7 +3029,7 @@ impl AccountsDb {
locked_entry.unref();
dead += 1;
} else {
alive_accounts.push((pubkey, stored_account));
alive_accounts.push(pair);
alive_total += stored_account.account_size;
alive += 1;
}

View File

@ -37,7 +37,7 @@ impl<'a> AccountsToStore<'a> {
/// available_bytes: how many bytes remain in the primary storage. Excess accounts will be directed to an overflow storage
pub fn new(
mut available_bytes: u64,
stored_accounts: &'a [(&'a Pubkey, &'a FoundStoredAccount<'a>)],
stored_accounts: &'a [&'a (Pubkey, FoundStoredAccount<'a>)],
slot: Slot,
) -> Self {
let num_accounts = stored_accounts.len();
@ -171,7 +171,8 @@ pub mod tests {
store_id,
account_size,
};
let map = vec![(&pubkey, &found)];
let item = (pubkey, found);
let map = vec![&item];
for (selector, available_bytes) in [
(StorageSelector::Primary, account_size),
(StorageSelector::Overflow, account_size - 1),
@ -182,7 +183,7 @@ pub mod tests {
assert_eq!(
accounts,
map.iter()
.map(|(a, b)| (*a, &b.account, slot))
.map(|(a, b)| (a, &b.account, slot))
.collect::<Vec<_>>(),
"mismatch"
);