From 294bda6a2e3d217db7656aebfddd0518dd0a507b Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Fri, 26 Jan 2024 04:53:24 -0800 Subject: [PATCH] [TieredStorage] Correct the HotStorage API for account_matches_owners --- accounts-db/src/tiered_storage/hot.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/accounts-db/src/tiered_storage/hot.rs b/accounts-db/src/tiered_storage/hot.rs index 8652b0b2aa9514..362cda38b232ca 100644 --- a/accounts-db/src/tiered_storage/hot.rs +++ b/accounts-db/src/tiered_storage/hot.rs @@ -361,7 +361,7 @@ impl HotStorageReader { pub fn account_matches_owners( &self, account_offset: HotAccountOffset, - owners: &[&Pubkey], + owners: &[Pubkey], ) -> Result { let account_meta = self .get_account_meta_from_offset(account_offset) @@ -376,7 +376,7 @@ impl HotStorageReader { owners .iter() - .position(|candidate| &account_owner == candidate) + .position(|candidate| account_owner == candidate) .ok_or(MatchAccountOwnerError::NoMatch) } } @@ -1065,7 +1065,7 @@ pub mod tests { let hot_storage = HotStorageReader::new_from_path(&path).unwrap(); // First, verify whether we can find the expected owners. - let mut owner_candidates: Vec<_> = owner_addresses.iter().collect(); + let mut owner_candidates = owner_addresses.clone(); owner_candidates.shuffle(&mut rng); for (account_offset, account_meta) in account_offsets.iter().zip(hot_account_metas.iter()) { @@ -1074,16 +1074,15 @@ pub mod tests { .unwrap(); assert_eq!( owner_candidates[index], - &owner_addresses[account_meta.owner_offset().0 as usize] + owner_addresses[account_meta.owner_offset().0 as usize] ); } // Second, verify the MatchAccountOwnerError::NoMatch case const NUM_UNMATCHED_OWNERS: usize = 20; - let unmatched_owners: Vec<_> = std::iter::repeat_with(Pubkey::new_unique) + let unmatched_candidates: Vec<_> = std::iter::repeat_with(Pubkey::new_unique) .take(NUM_UNMATCHED_OWNERS) .collect(); - let unmatched_candidates: Vec<_> = unmatched_owners.iter().collect(); for account_offset in account_offsets.iter() { assert_eq!( @@ -1103,7 +1102,7 @@ pub mod tests { .unwrap(); assert_eq!( owner_candidates[index], - &owner_addresses[account_meta.owner_offset().0 as usize] + owner_addresses[account_meta.owner_offset().0 as usize] ); } }