Skip to content

Commit

Permalink
[TieredStorage] Add TieredStorage::write_accounts_to_hot_storage() API
Browse files Browse the repository at this point in the history
  • Loading branch information
yhchiang-sol committed Mar 22, 2024
1 parent 8954981 commit 66c8caa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 2 additions & 8 deletions accounts-db/src/accounts_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use {
accounts_hash::AccountHash,
append_vec::{AppendVec, AppendVecError},
storable_accounts::StorableAccounts,
tiered_storage::{
error::TieredStorageError, hot::HOT_FORMAT, index::IndexOffset, TieredStorage,
},
tiered_storage::{error::TieredStorageError, index::IndexOffset, TieredStorage},
},
solana_sdk::{account::ReadableAccount, clock::Slot, pubkey::Pubkey},
std::{
Expand Down Expand Up @@ -239,11 +237,7 @@ impl AccountsFile {
) -> Option<Vec<StoredAccountInfo>> {
match self {
Self::AppendVec(av) => av.append_accounts(accounts, skip),
// Currently we only support HOT_FORMAT. If we later want to use
// a different format, then we will need a way to pass-in it.
// TODO: consider adding function like write_accounts_to_hot_storage() or something
// to hide implementation detail.
Self::TieredStorage(ts) => ts.write_accounts(accounts, skip, &HOT_FORMAT).ok(),
Self::TieredStorage(ts) => ts.write_accounts_to_hot_storage(accounts, skip).ok(),
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions accounts-db/src/tiered_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ impl TieredStorage {
}
}

pub fn write_accounts_to_hot_storage<
'a,
'b,
T: ReadableAccount + Sync,
U: StorableAccounts<'a, T>,
V: Borrow<AccountHash>,
>(
&self,
accounts: &StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>,
skip: usize,
) -> TieredStorageResult<Vec<StoredAccountInfo>> {
self.write_accounts(accounts, skip, &HOT_FORMAT)
}

/// Returns the underlying reader of the TieredStorage. None will be
/// returned if it's is_read_only() returns false.
pub fn reader(&self) -> Option<&TieredStorageReader> {
Expand Down

0 comments on commit 66c8caa

Please sign in to comment.