Accounts::store_accounts_cached uses StorableAccounts (#26112)

This commit is contained in:
Jeff Washington (jwash) 2022-06-22 12:13:56 -05:00 committed by GitHub
parent f3639b76ce
commit cf5ec13f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -7,7 +7,9 @@ use {
BankHashInfo, LoadHint, LoadedAccount, ScanStorageResult, BankHashInfo, LoadHint, LoadedAccount, ScanStorageResult,
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
}, },
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult}, accounts_index::{
AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport,
},
accounts_update_notifier_interface::AccountsUpdateNotifier, accounts_update_notifier_interface::AccountsUpdateNotifier,
ancestors::Ancestors, ancestors::Ancestors,
bank::{ bank::{
@ -16,6 +18,7 @@ use {
}, },
blockhash_queue::BlockhashQueue, blockhash_queue::BlockhashQueue,
rent_collector::RentCollector, rent_collector::RentCollector,
storable_accounts::StorableAccounts,
system_instruction_processor::{get_system_account_kind, SystemAccountKind}, system_instruction_processor::{get_system_account_kind, SystemAccountKind},
transaction_error_metrics::TransactionErrorMetrics, transaction_error_metrics::TransactionErrorMetrics,
}, },
@ -1206,8 +1209,11 @@ impl Accounts {
.store_cached((slot, &accounts_to_store[..]), Some(&txn_signatures)); .store_cached((slot, &accounts_to_store[..]), Some(&txn_signatures));
} }
pub fn store_accounts_cached(&self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)]) { pub fn store_accounts_cached<'a, T: ReadableAccount + Sync + ZeroLamport>(
self.accounts_db.store_cached((slot, accounts), None) &self,
accounts: impl StorableAccounts<'a, T>,
) {
self.accounts_db.store_cached(accounts, None)
} }
/// Add a slot to root. Root slots cannot be purged /// Add a slot to root. Root slots cannot be purged

View File

@ -6187,7 +6187,7 @@ impl Bank {
assert!(!self.freeze_started()); assert!(!self.freeze_started());
self.rc self.rc
.accounts .accounts
.store_accounts_cached(self.slot(), accounts); .store_accounts_cached((self.slot(), accounts));
let mut m = Measure::start("stakes_cache.check_and_store"); let mut m = Measure::start("stakes_cache.check_and_store");
for (pubkey, account) in accounts { for (pubkey, account) in accounts {
self.stakes_cache.check_and_store(pubkey, account); self.stakes_cache.check_and_store(pubkey, account);