From 69b6d5a376d2bf4ccfe5e6a58bf629a19ea25478 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang <93241502+yhchiang-sol@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:26:37 -0700 Subject: [PATCH] [TieredStorage] Remove the general-purposed TieredStorageWriter (#196) #### Problem tiered_storage/writer.rs was added when we planned to support multiple tiers in the tiered-storage (i.e., at least hot and cold). However, as we changed our plan to handle cold accounts as state-compressed accounts, we don't need a general purposed tiered-storage writer at this moment. #### Summary of Changes Remove tiered_storage/writer.rs as we currently don't have plans to develop cold storage. #### Test Plan Existing tiered-storage tests. --- accounts-db/src/tiered_storage.rs | 1 - accounts-db/src/tiered_storage/writer.rs | 63 ------------------------ 2 files changed, 64 deletions(-) delete mode 100644 accounts-db/src/tiered_storage/writer.rs diff --git a/accounts-db/src/tiered_storage.rs b/accounts-db/src/tiered_storage.rs index 2f8ebac65..e15adb388 100644 --- a/accounts-db/src/tiered_storage.rs +++ b/accounts-db/src/tiered_storage.rs @@ -11,7 +11,6 @@ pub mod mmap_utils; pub mod owners; pub mod readable; mod test_utils; -pub mod writer; use { crate::{ diff --git a/accounts-db/src/tiered_storage/writer.rs b/accounts-db/src/tiered_storage/writer.rs deleted file mode 100644 index 113d331e4..000000000 --- a/accounts-db/src/tiered_storage/writer.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! docs/src/proposals/append-vec-storage.md - -use { - crate::{ - account_storage::meta::{StorableAccountsWithHashesAndWriteVersions, StoredAccountInfo}, - accounts_hash::AccountHash, - storable_accounts::StorableAccounts, - tiered_storage::{ - error::TieredStorageError, file::TieredStorageFile, footer::TieredStorageFooter, - TieredStorageFormat, TieredStorageResult, - }, - }, - solana_sdk::account::ReadableAccount, - std::{borrow::Borrow, path::Path}, -}; - -#[derive(Debug)] -pub struct TieredStorageWriter<'format> { - storage: TieredStorageFile, - format: &'format TieredStorageFormat, -} - -impl<'format> TieredStorageWriter<'format> { - pub fn new( - file_path: impl AsRef, - format: &'format TieredStorageFormat, - ) -> TieredStorageResult { - Ok(Self { - storage: TieredStorageFile::new_writable(file_path)?, - format, - }) - } - - pub fn write_accounts< - 'a, - 'b, - T: ReadableAccount + Sync, - U: StorableAccounts<'a, T>, - V: Borrow, - >( - &self, - accounts: &StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>, - skip: usize, - ) -> TieredStorageResult> { - let footer = TieredStorageFooter { - account_meta_format: self.format.account_meta_format, - owners_block_format: self.format.owners_block_format, - account_block_format: self.format.account_block_format, - index_block_format: self.format.index_block_format, - account_entry_count: accounts - .accounts - .len() - .saturating_sub(skip) - .try_into() - .expect("num accounts <= u32::MAX"), - ..TieredStorageFooter::default() - }; - - footer.write_footer_block(&self.storage)?; - - Err(TieredStorageError::Unsupported()) - } -}