Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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