calculate_accounts_hash_without_index takes &self (#23846)
* calculate_accounts_hash_without_index takes &self * Update runtime/src/snapshot_package.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> Co-authored-by: Brooks Prumo <brooks@prumo.org>
This commit is contained in:
parent
7b89222fde
commit
b1280b670a
|
@ -10,7 +10,7 @@ use {
|
||||||
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
|
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts_db::{self, AccountsDb},
|
accounts_db::{self},
|
||||||
accounts_hash::HashStats,
|
accounts_hash::HashStats,
|
||||||
snapshot_config::SnapshotConfig,
|
snapshot_config::SnapshotConfig,
|
||||||
snapshot_package::{
|
snapshot_package::{
|
||||||
|
@ -129,7 +129,10 @@ impl AccountsHashVerifier {
|
||||||
let mut measure_hash = Measure::start("hash");
|
let mut measure_hash = Measure::start("hash");
|
||||||
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
||||||
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
||||||
let (hash, lamports) = AccountsDb::calculate_accounts_hash_without_index(
|
let (hash, lamports) = accounts_package
|
||||||
|
.accounts
|
||||||
|
.accounts_db
|
||||||
|
.calculate_accounts_hash_without_index(
|
||||||
ledger_path,
|
ledger_path,
|
||||||
&sorted_storages,
|
&sorted_storages,
|
||||||
thread_pool,
|
thread_pool,
|
||||||
|
@ -353,6 +356,7 @@ mod tests {
|
||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
..SnapshotConfig::default()
|
..SnapshotConfig::default()
|
||||||
};
|
};
|
||||||
|
let accounts = Arc::new(solana_runtime::accounts::Accounts::default_for_tests());
|
||||||
for i in 0..MAX_SNAPSHOT_HASHES + 1 {
|
for i in 0..MAX_SNAPSHOT_HASHES + 1 {
|
||||||
let accounts_package = AccountsPackage {
|
let accounts_package = AccountsPackage {
|
||||||
slot: full_snapshot_archive_interval_slots + i as u64,
|
slot: full_snapshot_archive_interval_slots + i as u64,
|
||||||
|
@ -368,6 +372,7 @@ mod tests {
|
||||||
hash_for_testing: None,
|
hash_for_testing: None,
|
||||||
cluster_type: ClusterType::MainnetBeta,
|
cluster_type: ClusterType::MainnetBeta,
|
||||||
snapshot_type: None,
|
snapshot_type: None,
|
||||||
|
accounts: Arc::clone(&accounts),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ledger_path = TempDir::new().unwrap();
|
let ledger_path = TempDir::new().unwrap();
|
||||||
|
|
|
@ -5524,7 +5524,7 @@ impl AccountsDb {
|
||||||
} else {
|
} else {
|
||||||
Some(&self.thread_pool_clean)
|
Some(&self.thread_pool_clean)
|
||||||
};
|
};
|
||||||
Self::calculate_accounts_hash_without_index(
|
self.calculate_accounts_hash_without_index(
|
||||||
&self.accounts_hash_cache_path,
|
&self.accounts_hash_cache_path,
|
||||||
&storages,
|
&storages,
|
||||||
thread_pool,
|
thread_pool,
|
||||||
|
@ -5728,6 +5728,7 @@ impl AccountsDb {
|
||||||
// modeled after get_accounts_delta_hash
|
// modeled after get_accounts_delta_hash
|
||||||
// intended to be faster than calculate_accounts_hash
|
// intended to be faster than calculate_accounts_hash
|
||||||
pub fn calculate_accounts_hash_without_index(
|
pub fn calculate_accounts_hash_without_index(
|
||||||
|
&self,
|
||||||
accounts_hash_cache_path: &Path,
|
accounts_hash_cache_path: &Path,
|
||||||
storages: &SortedStorages,
|
storages: &SortedStorages,
|
||||||
thread_pool: Option<&ThreadPool>,
|
thread_pool: Option<&ThreadPool>,
|
||||||
|
@ -7911,7 +7912,9 @@ pub mod tests {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
let (storages, _size, _slot_expected) = sample_storage();
|
let (storages, _size, _slot_expected) = sample_storage();
|
||||||
let result = AccountsDb::calculate_accounts_hash_without_index(
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
|
let result = db
|
||||||
|
.calculate_accounts_hash_without_index(
|
||||||
TempDir::new().unwrap().path(),
|
TempDir::new().unwrap().path(),
|
||||||
&get_storage_refs(&storages),
|
&get_storage_refs(&storages),
|
||||||
None,
|
None,
|
||||||
|
@ -7936,7 +7939,9 @@ pub mod tests {
|
||||||
item.hash
|
item.hash
|
||||||
});
|
});
|
||||||
let sum = raw_expected.iter().map(|item| item.lamports).sum();
|
let sum = raw_expected.iter().map(|item| item.lamports).sum();
|
||||||
let result = AccountsDb::calculate_accounts_hash_without_index(
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
|
let result = db
|
||||||
|
.calculate_accounts_hash_without_index(
|
||||||
TempDir::new().unwrap().path(),
|
TempDir::new().unwrap().path(),
|
||||||
&get_storage_refs(&storages),
|
&get_storage_refs(&storages),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
|
accounts::Accounts,
|
||||||
accounts_db::SnapshotStorages,
|
accounts_db::SnapshotStorages,
|
||||||
bank::{Bank, BankSlotDelta},
|
bank::{Bank, BankSlotDelta},
|
||||||
snapshot_archive_info::{SnapshotArchiveInfo, SnapshotArchiveInfoGetter},
|
snapshot_archive_info::{SnapshotArchiveInfo, SnapshotArchiveInfoGetter},
|
||||||
|
@ -47,6 +48,7 @@ pub struct AccountsPackage {
|
||||||
pub hash_for_testing: Option<Hash>,
|
pub hash_for_testing: Option<Hash>,
|
||||||
pub cluster_type: ClusterType,
|
pub cluster_type: ClusterType,
|
||||||
pub snapshot_type: Option<SnapshotType>,
|
pub snapshot_type: Option<SnapshotType>,
|
||||||
|
pub accounts: Arc<Accounts>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountsPackage {
|
impl AccountsPackage {
|
||||||
|
@ -109,6 +111,7 @@ impl AccountsPackage {
|
||||||
hash_for_testing,
|
hash_for_testing,
|
||||||
cluster_type: bank.cluster_type(),
|
cluster_type: bank.cluster_type(),
|
||||||
snapshot_type,
|
snapshot_type,
|
||||||
|
accounts: bank.accounts(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue