Skip to content

Commit

Permalink
[TieredStorage] Make AccountOffset use u32
Browse files Browse the repository at this point in the history
  • Loading branch information
yhchiang-sol committed Nov 17, 2023
1 parent 625e898 commit fde4a70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions accounts-db/src/tiered_storage/hot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl HotStorageReader {
&self,
account_offset: AccountOffset,
) -> TieredStorageResult<&HotAccountMeta> {
let (meta, _) = get_type::<HotAccountMeta>(&self.mmap, account_offset.block)?;
let (meta, _) = get_type::<HotAccountMeta>(&self.mmap, account_offset.block as usize)?;
Ok(meta)
}

Expand Down Expand Up @@ -467,7 +467,7 @@ pub mod tests {
.iter()
.map(|meta| {
let prev_offset = current_offset;
current_offset += file.write_type(meta).unwrap();
current_offset += file.write_type(meta).unwrap() as u32;
AccountOffset { block: prev_offset }
})
.collect();
Expand Down Expand Up @@ -532,7 +532,7 @@ pub mod tests {
let hot_storage = HotStorageReader::new_from_path(&path).unwrap();
for (i, index_writer_entry) in index_writer_entries.iter().enumerate() {
let account_offset = hot_storage.get_account_offset(IndexOffset(i)).unwrap();
assert_eq!(account_offset.block as u32, index_writer_entry.block_offset);
assert_eq!(account_offset.block, index_writer_entry.block_offset);

let account_address = hot_storage.get_account_address(IndexOffset(i)).unwrap();
assert_eq!(account_address, index_writer_entry.address);
Expand Down
8 changes: 4 additions & 4 deletions accounts-db/src/tiered_storage/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct AccountIndexWriterEntry<'a> {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct AccountOffset {
/// The offset to the accounts block that contains the account meta/data.
pub block: usize,
pub block: u32,
}

/// The offset to an account/address entry in the accounts index block.
Expand Down Expand Up @@ -103,10 +103,10 @@ impl IndexBlockFormat {
let account_offset = footer.index_block_offset as usize
+ std::mem::size_of::<Pubkey>() * footer.account_entry_count as usize
+ index_offset.0 * std::mem::size_of::<u32>();
let (block_offset, _) = get_type::<u32>(mmap, account_offset)?;
let (block_offset, _) = get_type(mmap, account_offset)?;

Ok(AccountOffset {
block: *block_offset as usize,
block: *block_offset,
})
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ mod tests {
let account_offset = indexer
.get_account_offset(&mmap, &footer, IndexOffset(i))
.unwrap();
assert_eq!(index_entry.block_offset, account_offset.block as u32);
assert_eq!(index_entry.block_offset, account_offset.block);
let address = indexer
.get_account_address(&mmap, &footer, IndexOffset(i))
.unwrap();
Expand Down

0 comments on commit fde4a70

Please sign in to comment.