From 874fae507f87606a4a6c5bbdf3ce68fa522a6b52 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang <93241502+yhchiang-sol@users.noreply.github.com> Date: Wed, 8 Nov 2023 21:58:44 -0800 Subject: [PATCH] [TieredStorage] Make HotStorageReader use AccountOffset type (#33964) #### Problem #33927 introduced a new type AccountOffset, but HotStorageReader still uses `usize` to access accounts. #### Summary of Changes This PR makes HotStorageReader use the new AccountOffset type. --- accounts-db/src/tiered_storage/hot.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accounts-db/src/tiered_storage/hot.rs b/accounts-db/src/tiered_storage/hot.rs index 9e987f886de101..f2efc1a966ca11 100644 --- a/accounts-db/src/tiered_storage/hot.rs +++ b/accounts-db/src/tiered_storage/hot.rs @@ -9,7 +9,7 @@ use { footer::{ AccountBlockFormat, AccountMetaFormat, OwnersBlockFormat, TieredStorageFooter, }, - index::IndexBlockFormat, + index::{AccountOffset, IndexBlockFormat}, meta::{AccountMetaFlags, AccountMetaOptionalFields, TieredAccountMeta}, mmap_utils::get_type, TieredStorageFormat, TieredStorageResult, @@ -223,8 +223,11 @@ impl HotStorageReader { } /// Returns the account meta located at the specified offset. - fn get_account_meta_from_offset(&self, offset: usize) -> TieredStorageResult<&HotAccountMeta> { - let (meta, _) = get_type::(&self.mmap, offset)?; + fn get_account_meta_from_offset( + &self, + account_offset: AccountOffset, + ) -> TieredStorageResult<&HotAccountMeta> { + let (meta, _) = get_type::(&self.mmap, account_offset.block)?; Ok(meta) } } @@ -241,7 +244,7 @@ pub mod tests { FOOTER_SIZE, }, hot::{HotAccountMeta, HotStorageReader}, - index::IndexBlockFormat, + index::{AccountOffset, IndexBlockFormat}, meta::{AccountMetaFlags, AccountMetaOptionalFields, TieredAccountMeta}, }, memoffset::offset_of, @@ -444,7 +447,7 @@ pub mod tests { .map(|meta| { let prev_offset = current_offset; current_offset += file.write_type(meta).unwrap(); - prev_offset + AccountOffset { block: prev_offset } }) .collect(); // while the test only focuses on account metas, writing a footer