Skip to content

Commit

Permalink
[TieredStorage] Disable accounts-file type check before enabling tier…
Browse files Browse the repository at this point in the history
…ed-storage (solana-labs#418)

#### Problem
As solana-labs#72 introduced AccountsFile::TieredStorage, it also performs
file-type check when opening an accounts-file to determine whether
it is a tiered-storage or an append-vec.  But before tiered-storage is
enabled, this opening check is unnecessary.

#### Summary of Changes
Remove the accounts-file type check code and simply assume everything
is append-vec on AccountsFile::new_from_file().
  • Loading branch information
yhchiang-sol authored Mar 25, 2024
1 parent b884ea8 commit c7dba30
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions accounts-db/src/accounts_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,8 @@ impl AccountsFile {
/// The second element of the returned tuple is the number of accounts in the
/// accounts file.
pub fn new_from_file(path: impl AsRef<Path>, current_len: usize) -> Result<(Self, usize)> {
match TieredStorage::new_readonly(path.as_ref()) {
Ok(tiered_storage) => {
// unwrap() note: TieredStorage::new_readonly() is guaranteed to have a valid
// reader instance when opening with new_readonly.
let num_accounts = tiered_storage.reader().unwrap().num_accounts();
Ok((Self::TieredStorage(tiered_storage), num_accounts))
}
Err(TieredStorageError::MagicNumberMismatch(_, _)) => {
// In case of MagicNumberMismatch, we can assume that this is not
// a tiered-storage file.
let (av, num_accounts) = AppendVec::new_from_file(path, current_len)?;
Ok((Self::AppendVec(av), num_accounts))
}
Err(e) => Err(AccountsFileError::TieredStorageError(e)),
}
let (av, num_accounts) = AppendVec::new_from_file(path, current_len)?;
Ok((Self::AppendVec(av), num_accounts))
}

pub fn flush(&self) -> Result<()> {
Expand Down

0 comments on commit c7dba30

Please sign in to comment.