From 66c8caa81836d1cecffde390a59e19dc73d6df6e Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Thu, 21 Mar 2024 18:51:09 -0700 Subject: [PATCH] [TieredStorage] Add TieredStorage::write_accounts_to_hot_storage() API --- accounts-db/src/accounts_file.rs | 10 ++-------- accounts-db/src/tiered_storage.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/accounts-db/src/accounts_file.rs b/accounts-db/src/accounts_file.rs index d8547398b7b206..cd04dc97de1f16 100644 --- a/accounts-db/src/accounts_file.rs +++ b/accounts-db/src/accounts_file.rs @@ -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::{ @@ -239,11 +237,7 @@ impl AccountsFile { ) -> Option> { 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(), } } } diff --git a/accounts-db/src/tiered_storage.rs b/accounts-db/src/tiered_storage.rs index 70169a59428fe6..0e240d00309175 100644 --- a/accounts-db/src/tiered_storage.rs +++ b/accounts-db/src/tiered_storage.rs @@ -143,6 +143,20 @@ impl TieredStorage { } } + pub fn write_accounts_to_hot_storage< + 'a, + 'b, + T: ReadableAccount + Sync, + U: StorableAccounts<'a, T>, + V: Borrow, + >( + &self, + accounts: &StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>, + skip: usize, + ) -> TieredStorageResult> { + 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> {