diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index eb9ae193fb1718..1dbfddfd6b2a28 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1316,7 +1316,7 @@ pub struct AccountsDb { write_cache_limit_bytes: Option, - sender_bg_hasher: Option>, + sender_bg_hasher: Option>>, read_only_accounts_cache: ReadOnlyAccountsCache, /// distribute the accounts across storage lists @@ -2752,17 +2752,19 @@ impl AccountsDb { } } - fn background_hasher(receiver: Receiver) { + fn background_hasher(receiver: Receiver>) { info!("Background account hasher has started"); loop { let result = receiver.recv(); match result { - Ok(account) => { - // if we hold the only ref, then this account doesn't need to be hashed, we ignore this account and it will disappear - if Arc::strong_count(&account) > 1 { - // this will cause the hash to be calculated and store inside account if it needs to be calculated - let _ = (*account).hash(); - }; + Ok(accounts) => { + for account in accounts { + // if we hold the only ref, then this account doesn't need to be hashed, we ignore this account and it will disappear + if Arc::strong_count(&account) > 1 { + // this will cause the hash to be calculated and store inside account if it needs to be calculated + let _ = (*account).hash(); + }; + } } Err(err) => { info!("Background account hasher is stopping because: {err}"); @@ -6388,7 +6390,7 @@ impl AccountsDb { Box::new(std::iter::empty()) }; - txn_iter + let (account_infos, cached_accounts) = txn_iter .enumerate() .map(|(i, txn)| { let mut account_info = AccountInfo::default(); @@ -6407,17 +6409,20 @@ impl AccountsDb { let cached_account = self.accounts_cache.store(slot, pubkey, account_shared_data); - // hash this account in the bg - match &self.sender_bg_hasher { - Some(ref sender) => { - let _ = sender.send(cached_account); - } - None => (), - }; - }); - account_info + (account_info, cached_account) + }) }) - .collect() + .unzip(); + + // hash this accounts in bg + match &self.sender_bg_hasher { + Some(ref sender) => { + let _ = sender.send(cached_accounts); + } + None => (), + }; + + account_infos } fn store_accounts_to<'a: 'c, 'b, 'c>(