Skip to content

Commit

Permalink
[TieredStorage] Improve param naming of IndexBlockFormat (solana-labs…
Browse files Browse the repository at this point in the history
…#34033)

#### Problem
In IndexBlockFormat, both `IndexOffset` and `AccountOffset` parameters
are named `offset` in some functions which could be confusing.

#### Summary of Changes
Renamed `offset` to `index_offset` and `account_offset` to improve
readability.
  • Loading branch information
yhchiang-sol committed Feb 13, 2024
1 parent f87c7e9 commit bacd2f1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions accounts-db/src/tiered_storage/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ impl IndexBlockFormat {
&self,
map: &'a Mmap,
footer: &TieredStorageFooter,
offset: IndexOffset,
index_offset: IndexOffset,
) -> TieredStorageResult<&'a Pubkey> {
let offset = match self {
let account_offset = match self {
Self::AddressAndOffset => {
footer.index_block_offset as usize + std::mem::size_of::<Pubkey>() * offset.0
footer.index_block_offset as usize + std::mem::size_of::<Pubkey>() * index_offset.0
}
};
let (address, _) = get_type::<Pubkey>(map, offset)?;
let (address, _) = get_type::<Pubkey>(map, account_offset)?;
Ok(address)
}

Expand All @@ -96,14 +96,14 @@ impl IndexBlockFormat {
&self,
map: &Mmap,
footer: &TieredStorageFooter,
offset: IndexOffset,
index_offset: IndexOffset,
) -> TieredStorageResult<AccountOffset> {
match self {
Self::AddressAndOffset => {
let offset = footer.index_block_offset as usize
let account_offset = footer.index_block_offset as usize
+ std::mem::size_of::<Pubkey>() * footer.account_entry_count as usize
+ offset.0 * std::mem::size_of::<u64>();
let (account_block_offset, _) = get_type(map, offset)?;
+ index_offset.0 * std::mem::size_of::<u64>();
let (account_block_offset, _) = get_type(map, account_offset)?;
Ok(AccountOffset {
block: *account_block_offset,
})
Expand Down

0 comments on commit bacd2f1

Please sign in to comment.