From 89c8775f31007eacc8a68cc429d22fa7df893e1d Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Wed, 15 Nov 2023 23:58:03 -0800 Subject: [PATCH] [TieredStorage] Define OwnerOffset as u32 --- accounts-db/src/tiered_storage/hot.rs | 4 +++- accounts-db/src/tiered_storage/owners.rs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/accounts-db/src/tiered_storage/hot.rs b/accounts-db/src/tiered_storage/hot.rs index cd5924ee10d0b7..a72ab83c5c5414 100644 --- a/accounts-db/src/tiered_storage/hot.rs +++ b/accounts-db/src/tiered_storage/hot.rs @@ -571,7 +571,9 @@ pub mod tests { let hot_storage = HotStorageReader::new_from_path(&path).unwrap(); for (i, address) in addresses.iter().enumerate() { assert_eq!( - hot_storage.get_owner_address(OwnerOffset(i)).unwrap(), + hot_storage + .get_owner_address(OwnerOffset(i as u32)) + .unwrap(), address, ); } diff --git a/accounts-db/src/tiered_storage/owners.rs b/accounts-db/src/tiered_storage/owners.rs index 10ea4cc94b9cf4..3afdfaed73d57a 100644 --- a/accounts-db/src/tiered_storage/owners.rs +++ b/accounts-db/src/tiered_storage/owners.rs @@ -16,7 +16,7 @@ pub struct OwnersBlock; /// The offset to an owner entry in the owners block. /// This is used to obtain the address of the account owner. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct OwnerOffset(pub usize); +pub struct OwnerOffset(pub u32); /// OwnersBlock is persisted as a consecutive bytes of pubkeys without any /// meta-data. For each account meta, it has a owner_offset field to @@ -42,8 +42,8 @@ impl OwnersBlock { footer: &TieredStorageFooter, owner_offset: OwnerOffset, ) -> TieredStorageResult<&'a Pubkey> { - let offset = - footer.owners_block_offset as usize + (std::mem::size_of::() * owner_offset.0); + let offset = footer.owners_block_offset as usize + + (std::mem::size_of::() * owner_offset.0 as usize); let (pubkey, _) = get_type::(mmap, offset)?; Ok(pubkey) @@ -90,7 +90,7 @@ mod tests { for (i, address) in addresses.iter().enumerate() { assert_eq!( - OwnersBlock::get_owner_address(&mmap, &footer, OwnerOffset(i)).unwrap(), + OwnersBlock::get_owner_address(&mmap, &footer, OwnerOffset(i as u32)).unwrap(), address ); }