introduce BinnedHashData type to improve some code readability (#19722)
This commit is contained in:
committed by
GitHub
parent
1cf7ae51f8
commit
97418bede3
@ -129,6 +129,8 @@ pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig
|
|||||||
index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
|
index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub type BinnedHashData = Vec<Vec<CalculateHashIntermediate>>;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct AccountsDbConfig {
|
pub struct AccountsDbConfig {
|
||||||
pub index: Option<AccountsIndexConfig>,
|
pub index: Option<AccountsIndexConfig>,
|
||||||
@ -5128,7 +5130,7 @@ impl AccountsDb {
|
|||||||
&Ancestors,
|
&Ancestors,
|
||||||
&AccountInfoAccountsIndex,
|
&AccountInfoAccountsIndex,
|
||||||
)>,
|
)>,
|
||||||
) -> Result<Vec<Vec<Vec<CalculateHashIntermediate>>>, BankHashVerificationError> {
|
) -> Result<Vec<BinnedHashData>, BankHashVerificationError> {
|
||||||
let bin_calculator = PubkeyBinCalculator16::new(bins);
|
let bin_calculator = PubkeyBinCalculator16::new(bins);
|
||||||
assert!(bin_range.start < bins && bin_range.end <= bins && bin_range.start < bin_range.end);
|
assert!(bin_range.start < bins && bin_range.end <= bins && bin_range.start < bin_range.end);
|
||||||
let mut time = Measure::start("scan all accounts");
|
let mut time = Measure::start("scan all accounts");
|
||||||
@ -5137,12 +5139,10 @@ impl AccountsDb {
|
|||||||
let range = bin_range.end - bin_range.start;
|
let range = bin_range.end - bin_range.start;
|
||||||
let sort_time = AtomicU64::new(0);
|
let sort_time = AtomicU64::new(0);
|
||||||
|
|
||||||
let result: Vec<Vec<Vec<CalculateHashIntermediate>>> = Self::scan_account_storage_no_bank(
|
let result: Vec<BinnedHashData> = Self::scan_account_storage_no_bank(
|
||||||
accounts_cache_and_ancestors,
|
accounts_cache_and_ancestors,
|
||||||
storage,
|
storage,
|
||||||
|loaded_account: LoadedAccount,
|
|loaded_account: LoadedAccount, accum: &mut BinnedHashData, slot: Slot| {
|
||||||
accum: &mut Vec<Vec<CalculateHashIntermediate>>,
|
|
||||||
slot: Slot| {
|
|
||||||
let pubkey = loaded_account.pubkey();
|
let pubkey = loaded_account.pubkey();
|
||||||
let mut pubkey_to_bin_index = bin_calculator.bin_from_pubkey(pubkey);
|
let mut pubkey_to_bin_index = bin_calculator.bin_from_pubkey(pubkey);
|
||||||
if !bin_range.contains(&pubkey_to_bin_index) {
|
if !bin_range.contains(&pubkey_to_bin_index) {
|
||||||
@ -5203,9 +5203,7 @@ impl AccountsDb {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sort_slot_storage_scan(
|
fn sort_slot_storage_scan(accum: BinnedHashData) -> (BinnedHashData, u64) {
|
||||||
accum: Vec<Vec<CalculateHashIntermediate>>,
|
|
||||||
) -> (Vec<Vec<CalculateHashIntermediate>>, u64) {
|
|
||||||
let time = AtomicU64::new(0);
|
let time = AtomicU64::new(0);
|
||||||
(
|
(
|
||||||
accum
|
accum
|
||||||
@ -6736,7 +6734,7 @@ pub mod tests {
|
|||||||
bins: usize,
|
bins: usize,
|
||||||
bin_range: &Range<usize>,
|
bin_range: &Range<usize>,
|
||||||
check_hash: bool,
|
check_hash: bool,
|
||||||
) -> Result<Vec<Vec<Vec<CalculateHashIntermediate>>>, BankHashVerificationError> {
|
) -> Result<Vec<BinnedHashData>, BankHashVerificationError> {
|
||||||
Self::scan_snapshot_stores_with_cache(storage, stats, bins, bin_range, check_hash, None)
|
Self::scan_snapshot_stores_with_cache(storage, stats, bins, bin_range, check_hash, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user