Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 6276360468)
Co-authored-by: carllin <wumu727@gmail.com>
This commit is contained in:
@@ -462,16 +462,16 @@ impl Accounts {
|
||||
}
|
||||
|
||||
pub fn calculate_capitalization(&self, ancestors: &Ancestors) -> u64 {
|
||||
let balances = self
|
||||
.load_all(ancestors)
|
||||
.into_iter()
|
||||
.map(|(_pubkey, account, _slot)| {
|
||||
AccountsDB::account_balance_for_capitalization(
|
||||
account.lamports,
|
||||
&account.owner,
|
||||
account.executable,
|
||||
)
|
||||
});
|
||||
let balances =
|
||||
self.load_all_unchecked(ancestors)
|
||||
.into_iter()
|
||||
.map(|(_pubkey, account, _slot)| {
|
||||
AccountsDB::account_balance_for_capitalization(
|
||||
account.lamports,
|
||||
&account.owner,
|
||||
account.executable,
|
||||
)
|
||||
});
|
||||
|
||||
AccountsDB::checked_sum_for_capitalization(balances)
|
||||
}
|
||||
@@ -541,6 +541,19 @@ impl Accounts {
|
||||
)
|
||||
}
|
||||
|
||||
fn load_all_unchecked(&self, ancestors: &Ancestors) -> Vec<(Pubkey, Account, Slot)> {
|
||||
self.accounts_db.unchecked_scan_accounts(
|
||||
ancestors,
|
||||
|collector: &mut Vec<(Pubkey, Account, Slot)>, some_account_tuple| {
|
||||
if let Some((pubkey, account, slot)) =
|
||||
some_account_tuple.filter(|(_, account, _)| Self::is_loadable(account))
|
||||
{
|
||||
collector.push((*pubkey, account, slot))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn load_to_collect_rent_eagerly<R: RangeBounds<Pubkey>>(
|
||||
&self,
|
||||
ancestors: &Ancestors,
|
||||
|
||||
Reference in New Issue
Block a user