Rename AccountsPacakge to SnapshotPackage and AccountsPackagePre to AccountsPackage (#19231)
Renaming these types to better communicate their usages, which will further diverge as incremental snapshot support is added. With the new names, AccountsPacakge now refers to the type between AccountsBackgroundProcess and AccountsHashVerifier, and SnapshotPackage refers to the type between AccountsHashVerifier and SnapshotPackagerService.
This commit is contained in:
@ -20,12 +20,12 @@ use std::{
|
||||
};
|
||||
use tempfile::TempDir;
|
||||
|
||||
pub type AccountsPackageSender = Sender<AccountsPackagePre>;
|
||||
pub type AccountsPackageReceiver = Receiver<AccountsPackagePre>;
|
||||
pub type AccountsPackageSendError = SendError<AccountsPackagePre>;
|
||||
pub type AccountsPackageSender = Sender<AccountsPackage>;
|
||||
pub type AccountsPackageReceiver = Receiver<AccountsPackage>;
|
||||
pub type AccountsPackageSendError = SendError<AccountsPackage>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AccountsPackagePre {
|
||||
pub struct AccountsPackage {
|
||||
pub slot: Slot,
|
||||
pub block_height: Slot,
|
||||
pub slot_deltas: Vec<BankSlotDelta>,
|
||||
@ -40,8 +40,8 @@ pub struct AccountsPackagePre {
|
||||
pub cluster_type: ClusterType,
|
||||
}
|
||||
|
||||
impl AccountsPackagePre {
|
||||
/// Create a snapshot package
|
||||
impl AccountsPackage {
|
||||
/// Create an accounts package
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn new(
|
||||
bank: &Bank,
|
||||
@ -84,7 +84,7 @@ impl AccountsPackagePre {
|
||||
|
||||
/// Package up bank snapshot files, snapshot storages, and slot deltas for a full snapshot.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new_full_snapshot_package(
|
||||
pub fn new_for_full_snapshot(
|
||||
bank: &Bank,
|
||||
bank_snapshot_info: &BankSnapshotInfo,
|
||||
snapshots_dir: impl AsRef<Path>,
|
||||
@ -120,7 +120,7 @@ impl AccountsPackagePre {
|
||||
|
||||
/// Package up bank snapshot files, snapshot storages, and slot deltas for an incremental snapshot.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new_incremental_snapshot_package(
|
||||
pub fn new_for_incremental_snapshot(
|
||||
bank: &Bank,
|
||||
incremental_snapshot_base_slot: Slot,
|
||||
bank_snapshot_info: &BankSnapshotInfo,
|
||||
@ -169,7 +169,7 @@ impl AccountsPackagePre {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AccountsPackage {
|
||||
pub struct SnapshotPackage {
|
||||
pub snapshot_archive_info: SnapshotArchiveInfo,
|
||||
pub block_height: Slot,
|
||||
pub slot_deltas: Vec<BankSlotDelta>,
|
||||
@ -178,7 +178,7 @@ pub struct AccountsPackage {
|
||||
pub snapshot_version: SnapshotVersion,
|
||||
}
|
||||
|
||||
impl AccountsPackage {
|
||||
impl SnapshotPackage {
|
||||
pub fn new(
|
||||
slot: Slot,
|
||||
block_height: u64,
|
||||
@ -206,7 +206,7 @@ impl AccountsPackage {
|
||||
}
|
||||
}
|
||||
|
||||
impl SnapshotArchiveInfoGetter for AccountsPackage {
|
||||
impl SnapshotArchiveInfoGetter for SnapshotPackage {
|
||||
fn snapshot_archive_info(&self) -> &SnapshotArchiveInfo {
|
||||
&self.snapshot_archive_info
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use {
|
||||
FullSnapshotArchiveInfo, IncrementalSnapshotArchiveInfo, SnapshotArchiveInfoGetter,
|
||||
},
|
||||
snapshot_package::{
|
||||
AccountsPackage, AccountsPackagePre, AccountsPackageSendError, AccountsPackageSender,
|
||||
AccountsPackage, AccountsPackageSendError, AccountsPackageSender, SnapshotPackage,
|
||||
},
|
||||
sorted_storages::SortedStorages,
|
||||
},
|
||||
@ -239,9 +239,9 @@ pub fn remove_tmp_snapshot_archives(snapshot_archives_dir: &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Make a full snapshot archive out of the AccountsPackage
|
||||
/// Make a full snapshot archive out of the snapshot package
|
||||
pub fn archive_snapshot_package(
|
||||
snapshot_package: &AccountsPackage,
|
||||
snapshot_package: &SnapshotPackage,
|
||||
maximum_snapshots_to_retain: usize,
|
||||
) -> Result<()> {
|
||||
info!(
|
||||
@ -1549,7 +1549,7 @@ pub fn snapshot_bank(
|
||||
let highest_bank_snapshot_info = get_highest_bank_snapshot_info(snapshots_dir)
|
||||
.expect("no snapshots found in config snapshots_dir");
|
||||
|
||||
let package = AccountsPackagePre::new_full_snapshot_package(
|
||||
let accounts_package = AccountsPackage::new_for_full_snapshot(
|
||||
root_bank,
|
||||
&highest_bank_snapshot_info,
|
||||
snapshots_dir,
|
||||
@ -1561,7 +1561,7 @@ pub fn snapshot_bank(
|
||||
hash_for_testing,
|
||||
)?;
|
||||
|
||||
accounts_package_sender.send(package)?;
|
||||
accounts_package_sender.send(accounts_package)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1666,7 +1666,7 @@ pub fn package_process_and_archive_full_snapshot(
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
maximum_snapshots_to_retain: usize,
|
||||
) -> Result<FullSnapshotArchiveInfo> {
|
||||
let package = AccountsPackagePre::new_full_snapshot_package(
|
||||
let accounts_package = AccountsPackage::new_for_full_snapshot(
|
||||
bank,
|
||||
bank_snapshot_info,
|
||||
snapshots_dir,
|
||||
@ -1678,14 +1678,16 @@ pub fn package_process_and_archive_full_snapshot(
|
||||
None,
|
||||
)?;
|
||||
|
||||
let package = process_and_archive_snapshot_package_pre(
|
||||
package,
|
||||
let snapshot_package = process_and_archive_accounts_package(
|
||||
accounts_package,
|
||||
thread_pool,
|
||||
None,
|
||||
maximum_snapshots_to_retain,
|
||||
)?;
|
||||
|
||||
Ok(FullSnapshotArchiveInfo::new(package.snapshot_archive_info))
|
||||
Ok(FullSnapshotArchiveInfo::new(
|
||||
snapshot_package.snapshot_archive_info,
|
||||
))
|
||||
}
|
||||
|
||||
/// Helper function to hold shared code to package, process, and archive incremental snapshots
|
||||
@ -1702,7 +1704,7 @@ pub fn package_process_and_archive_incremental_snapshot(
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
maximum_snapshots_to_retain: usize,
|
||||
) -> Result<IncrementalSnapshotArchiveInfo> {
|
||||
let package = AccountsPackagePre::new_incremental_snapshot_package(
|
||||
let accounts_package = AccountsPackage::new_for_incremental_snapshot(
|
||||
bank,
|
||||
incremental_snapshot_base_slot,
|
||||
bank_snapshot_info,
|
||||
@ -1715,8 +1717,8 @@ pub fn package_process_and_archive_incremental_snapshot(
|
||||
None,
|
||||
)?;
|
||||
|
||||
let package = process_and_archive_snapshot_package_pre(
|
||||
package,
|
||||
let snapshot_package = process_and_archive_accounts_package(
|
||||
accounts_package,
|
||||
thread_pool,
|
||||
Some(incremental_snapshot_base_slot),
|
||||
maximum_snapshots_to_retain,
|
||||
@ -1724,30 +1726,33 @@ pub fn package_process_and_archive_incremental_snapshot(
|
||||
|
||||
Ok(IncrementalSnapshotArchiveInfo::new(
|
||||
incremental_snapshot_base_slot,
|
||||
package.snapshot_archive_info,
|
||||
snapshot_package.snapshot_archive_info,
|
||||
))
|
||||
}
|
||||
|
||||
/// Helper function to hold shared code to process and archive snapshot packages
|
||||
fn process_and_archive_snapshot_package_pre(
|
||||
package_pre: AccountsPackagePre,
|
||||
/// Helper function to hold shared code to process and archive accounts packages
|
||||
fn process_and_archive_accounts_package(
|
||||
accounts_package: AccountsPackage,
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
incremental_snapshot_base_slot: Option<Slot>,
|
||||
maximum_snapshots_to_retain: usize,
|
||||
) -> Result<AccountsPackage> {
|
||||
let package =
|
||||
process_accounts_package_pre(package_pre, thread_pool, incremental_snapshot_base_slot);
|
||||
) -> Result<SnapshotPackage> {
|
||||
let snapshot_package = process_accounts_package(
|
||||
accounts_package,
|
||||
thread_pool,
|
||||
incremental_snapshot_base_slot,
|
||||
);
|
||||
|
||||
archive_snapshot_package(&package, maximum_snapshots_to_retain)?;
|
||||
archive_snapshot_package(&snapshot_package, maximum_snapshots_to_retain)?;
|
||||
|
||||
Ok(package)
|
||||
Ok(snapshot_package)
|
||||
}
|
||||
|
||||
pub fn process_accounts_package_pre(
|
||||
accounts_package: AccountsPackagePre,
|
||||
pub fn process_accounts_package(
|
||||
accounts_package: AccountsPackage,
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
incremental_snapshot_base_slot: Option<Slot>,
|
||||
) -> AccountsPackage {
|
||||
) -> SnapshotPackage {
|
||||
let mut time = Measure::start("hash");
|
||||
|
||||
let hash = accounts_package.hash; // temporarily remaining here
|
||||
@ -1789,7 +1794,7 @@ pub fn process_accounts_package_pre(
|
||||
),
|
||||
};
|
||||
|
||||
AccountsPackage::new(
|
||||
SnapshotPackage::new(
|
||||
accounts_package.slot,
|
||||
accounts_package.block_height,
|
||||
accounts_package.slot_deltas,
|
||||
|
Reference in New Issue
Block a user