From cf5ec13f598bd583af74ab44cf861591e9bd77dc Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 22 Jun 2022 12:13:56 -0500 Subject: [PATCH] Accounts::store_accounts_cached uses StorableAccounts (#26112) --- runtime/src/accounts.rs | 12 +++++++++--- runtime/src/bank.rs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 01ebddb42..c7004bb45 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -7,7 +7,9 @@ use { BankHashInfo, LoadHint, LoadedAccount, ScanStorageResult, 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, ancestors::Ancestors, bank::{ @@ -16,6 +18,7 @@ use { }, blockhash_queue::BlockhashQueue, rent_collector::RentCollector, + storable_accounts::StorableAccounts, system_instruction_processor::{get_system_account_kind, SystemAccountKind}, transaction_error_metrics::TransactionErrorMetrics, }, @@ -1206,8 +1209,11 @@ impl Accounts { .store_cached((slot, &accounts_to_store[..]), Some(&txn_signatures)); } - pub fn store_accounts_cached(&self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)]) { - self.accounts_db.store_cached((slot, accounts), None) + pub fn store_accounts_cached<'a, T: ReadableAccount + Sync + ZeroLamport>( + &self, + accounts: impl StorableAccounts<'a, T>, + ) { + self.accounts_db.store_cached(accounts, None) } /// Add a slot to root. Root slots cannot be purged diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 5a7c0f88b..4b54c8090 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6187,7 +6187,7 @@ impl Bank { assert!(!self.freeze_started()); self.rc .accounts - .store_accounts_cached(self.slot(), accounts); + .store_accounts_cached((self.slot(), accounts)); let mut m = Measure::start("stakes_cache.check_and_store"); for (pubkey, account) in accounts { self.stakes_cache.check_and_store(pubkey, account);