Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 11 additions & 9 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5981,7 +5981,7 @@ impl AccountsDb {
let mut append_accounts = Measure::start("append_accounts");
let rvs = storage
.accounts
.append_accounts(accounts_and_meta_to_store, infos.len());
.append_accounts(accounts_and_meta_to_store.accounts, infos.len());
append_accounts.stop();
total_append_accounts_us += append_accounts.as_us();
if rvs.is_none() {
Expand Down Expand Up @@ -9716,7 +9716,7 @@ pub mod tests {
let append = StorableAccountsWithHashes::new_with_hashes(&storable, hashes);

// construct append vec with account to generate an index from
append_vec.accounts.append_accounts(&append, 0);
append_vec.accounts.append_accounts(append.accounts, 0);
// append vecs set this at load
append_vec
.approx_store_count
Expand Down Expand Up @@ -10205,7 +10205,7 @@ pub mod tests {
StorableAccountsWithHashes::new_with_hashes(&account_data, hashes);
copied_storage
.accounts
.append_accounts(&storable_accounts, 0);
.append_accounts(storable_accounts.accounts, 0);
copied_storage
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -10249,7 +10249,7 @@ pub mod tests {
StorableAccountsWithHashes::new_with_hashes(&account_data, hashes);
copied_storage
.accounts
.append_accounts(&storable_accounts, 0);
.append_accounts(storable_accounts.accounts, 0);
copied_storage
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -10719,7 +10719,7 @@ pub mod tests {
StorableAccountsWithHashes::new_with_hashes(&account_data, vec![&hash]);
let stored_accounts_info = storage
.accounts
.append_accounts(&storable_accounts, 0)
.append_accounts(storable_accounts.accounts, 0)
.unwrap();
if mark_alive {
// updates 'alive_bytes' on the storage
Expand Down Expand Up @@ -15170,10 +15170,11 @@ pub mod tests {
let storage = accounts.create_and_insert_store(slot0, 4_000, "flush_slot_cache");
let hashes = vec![AccountHash(Hash::default()); 1];
storage.accounts.append_accounts(
&StorableAccountsWithHashes::new_with_hashes(
StorableAccountsWithHashes::new_with_hashes(
&(slot0, &[(&shared_key, &account)][..]),
hashes,
),
)
.accounts,
0,
);

Expand Down Expand Up @@ -15246,10 +15247,11 @@ pub mod tests {
let storage = accounts.create_and_insert_store(slot0, 4_000, "flush_slot_cache");
let hashes = vec![AccountHash(Hash::default()); 2];
storage.accounts.append_accounts(
&StorableAccountsWithHashes::new_with_hashes(
StorableAccountsWithHashes::new_with_hashes(
&(slot0, &[(&keys[0], &account), (&keys[1], &account_big)][..]),
hashes,
),
)
.accounts,
0,
);

Expand Down
12 changes: 5 additions & 7 deletions accounts-db/src/accounts_file.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use {
crate::{
account_info::AccountInfo,
account_storage::meta::{StorableAccountsWithHashes, StoredAccountInfo, StoredAccountMeta},
account_storage::meta::{StoredAccountInfo, StoredAccountMeta},
accounts_db::AccountsFileId,
accounts_hash::AccountHash,
append_vec::{AppendVec, AppendVecError, IndexInfo},
storable_accounts::StorableAccounts,
tiered_storage::{
Expand All @@ -12,7 +11,6 @@ use {
},
solana_sdk::{account::AccountSharedData, clock::Slot, pubkey::Pubkey},
std::{
borrow::Borrow,
io::Read,
mem,
path::{Path, PathBuf},
Expand Down Expand Up @@ -266,18 +264,18 @@ impl AccountsFile {
/// So, return.len() is 1 + (number of accounts written)
/// After each account is appended, the internal `current_len` is updated
/// and will be available to other threads.
pub fn append_accounts<'a, 'b, U: StorableAccounts<'a>, V: Borrow<AccountHash>>(
pub fn append_accounts<'a>(
&self,
accounts: &StorableAccountsWithHashes<'a, 'b, U, V>,
accounts: &impl StorableAccounts<'a>,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the main change.

skip: usize,
) -> Option<Vec<StoredAccountInfo>> {
match self {
Self::AppendVec(av) => av.append_accounts(accounts.accounts, skip),
Self::AppendVec(av) => av.append_accounts(accounts, skip),
// Note: The conversion here is needed as the AccountsDB currently
// assumes all offsets are multiple of 8 while TieredStorage uses
// IndexOffset that is equivalent to AccountInfo::reduced_offset.
Self::TieredStorage(ts) => ts
.write_accounts(accounts.accounts, skip, &HOT_FORMAT)
.write_accounts(accounts, skip, &HOT_FORMAT)
.map(|mut infos| {
infos.iter_mut().for_each(|info| {
info.offset = AccountInfo::reduced_offset_to_offset(info.offset as u32);
Expand Down