Simplify AccountsPackagePre::new() and friends (#19134)
This commit is contained in:
@ -41,53 +41,19 @@ pub struct AccountsPackagePre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AccountsPackagePre {
|
impl AccountsPackagePre {
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn new(
|
|
||||||
slot: Slot,
|
|
||||||
block_height: u64,
|
|
||||||
slot_deltas: Vec<BankSlotDelta>,
|
|
||||||
snapshot_links: TempDir,
|
|
||||||
storages: SnapshotStorages,
|
|
||||||
hash: Hash,
|
|
||||||
archive_format: ArchiveFormat,
|
|
||||||
snapshot_version: SnapshotVersion,
|
|
||||||
snapshot_output_dir: PathBuf,
|
|
||||||
expected_capitalization: u64,
|
|
||||||
hash_for_testing: Option<Hash>,
|
|
||||||
cluster_type: ClusterType,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
slot,
|
|
||||||
block_height,
|
|
||||||
slot_deltas,
|
|
||||||
snapshot_links,
|
|
||||||
storages,
|
|
||||||
hash,
|
|
||||||
archive_format,
|
|
||||||
snapshot_version,
|
|
||||||
snapshot_output_dir,
|
|
||||||
expected_capitalization,
|
|
||||||
hash_for_testing,
|
|
||||||
cluster_type,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a snapshot package
|
/// Create a snapshot package
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn new_snapshot_package<P>(
|
fn new(
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
bank_snapshot_info: &BankSnapshotInfo,
|
bank_snapshot_info: &BankSnapshotInfo,
|
||||||
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
||||||
snapshot_package_output_path: P,
|
snapshot_package_output_path: impl AsRef<Path>,
|
||||||
snapshot_storages: SnapshotStorages,
|
snapshot_storages: SnapshotStorages,
|
||||||
archive_format: ArchiveFormat,
|
archive_format: ArchiveFormat,
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
hash_for_testing: Option<Hash>,
|
hash_for_testing: Option<Hash>,
|
||||||
snapshot_tmpdir: TempDir,
|
snapshot_tmpdir: TempDir,
|
||||||
) -> Result<Self>
|
) -> Result<Self> {
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
{
|
|
||||||
// Hard link the snapshot into a tmpdir, to ensure its not removed prior to packaging.
|
// Hard link the snapshot into a tmpdir, to ensure its not removed prior to packaging.
|
||||||
{
|
{
|
||||||
let snapshot_hardlink_dir = snapshot_tmpdir
|
let snapshot_hardlink_dir = snapshot_tmpdir
|
||||||
@ -100,39 +66,35 @@ impl AccountsPackagePre {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self::new(
|
Ok(Self {
|
||||||
bank.slot(),
|
slot: bank.slot(),
|
||||||
bank.block_height(),
|
block_height: bank.block_height(),
|
||||||
status_cache_slot_deltas,
|
slot_deltas: status_cache_slot_deltas,
|
||||||
snapshot_tmpdir,
|
snapshot_links: snapshot_tmpdir,
|
||||||
snapshot_storages,
|
storages: snapshot_storages,
|
||||||
bank.get_accounts_hash(),
|
hash: bank.get_accounts_hash(),
|
||||||
archive_format,
|
archive_format,
|
||||||
snapshot_version,
|
snapshot_version,
|
||||||
snapshot_package_output_path.as_ref().to_path_buf(),
|
snapshot_output_dir: snapshot_package_output_path.as_ref().to_path_buf(),
|
||||||
bank.capitalization(),
|
expected_capitalization: bank.capitalization(),
|
||||||
hash_for_testing,
|
hash_for_testing,
|
||||||
bank.cluster_type(),
|
cluster_type: bank.cluster_type(),
|
||||||
))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package up bank snapshot files, snapshot storages, and slot deltas for a full snapshot.
|
/// Package up bank snapshot files, snapshot storages, and slot deltas for a full snapshot.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new_full_snapshot_package<P, Q>(
|
pub fn new_full_snapshot_package(
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
bank_snapshot_info: &BankSnapshotInfo,
|
bank_snapshot_info: &BankSnapshotInfo,
|
||||||
snapshots_dir: P,
|
snapshots_dir: impl AsRef<Path>,
|
||||||
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
||||||
snapshot_package_output_path: Q,
|
snapshot_package_output_path: impl AsRef<Path>,
|
||||||
snapshot_storages: SnapshotStorages,
|
snapshot_storages: SnapshotStorages,
|
||||||
archive_format: ArchiveFormat,
|
archive_format: ArchiveFormat,
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
hash_for_testing: Option<Hash>,
|
hash_for_testing: Option<Hash>,
|
||||||
) -> Result<Self>
|
) -> Result<Self> {
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
Q: AsRef<Path>,
|
|
||||||
{
|
|
||||||
info!(
|
info!(
|
||||||
"Package full snapshot for bank: {} has {} account storage entries",
|
"Package full snapshot for bank: {} has {} account storage entries",
|
||||||
bank.slot(),
|
bank.slot(),
|
||||||
@ -143,7 +105,7 @@ impl AccountsPackagePre {
|
|||||||
.prefix(&format!("{}{}-", TMP_FULL_SNAPSHOT_PREFIX, bank.slot()))
|
.prefix(&format!("{}{}-", TMP_FULL_SNAPSHOT_PREFIX, bank.slot()))
|
||||||
.tempdir_in(snapshots_dir)?;
|
.tempdir_in(snapshots_dir)?;
|
||||||
|
|
||||||
Self::new_snapshot_package(
|
Self::new(
|
||||||
bank,
|
bank,
|
||||||
bank_snapshot_info,
|
bank_snapshot_info,
|
||||||
status_cache_slot_deltas,
|
status_cache_slot_deltas,
|
||||||
@ -158,22 +120,18 @@ impl AccountsPackagePre {
|
|||||||
|
|
||||||
/// Package up bank snapshot files, snapshot storages, and slot deltas for an incremental snapshot.
|
/// Package up bank snapshot files, snapshot storages, and slot deltas for an incremental snapshot.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new_incremental_snapshot_package<P, Q>(
|
pub fn new_incremental_snapshot_package(
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
incremental_snapshot_base_slot: Slot,
|
incremental_snapshot_base_slot: Slot,
|
||||||
bank_snapshot_info: &BankSnapshotInfo,
|
bank_snapshot_info: &BankSnapshotInfo,
|
||||||
snapshots_dir: P,
|
snapshots_dir: impl AsRef<Path>,
|
||||||
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
status_cache_slot_deltas: Vec<BankSlotDelta>,
|
||||||
snapshot_package_output_path: Q,
|
snapshot_package_output_path: impl AsRef<Path>,
|
||||||
snapshot_storages: SnapshotStorages,
|
snapshot_storages: SnapshotStorages,
|
||||||
archive_format: ArchiveFormat,
|
archive_format: ArchiveFormat,
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
hash_for_testing: Option<Hash>,
|
hash_for_testing: Option<Hash>,
|
||||||
) -> Result<Self>
|
) -> Result<Self> {
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
Q: AsRef<Path>,
|
|
||||||
{
|
|
||||||
info!(
|
info!(
|
||||||
"Package incremental snapshot for bank {} (from base slot {}) has {} account storage entries",
|
"Package incremental snapshot for bank {} (from base slot {}) has {} account storage entries",
|
||||||
bank.slot(),
|
bank.slot(),
|
||||||
@ -197,7 +155,7 @@ impl AccountsPackagePre {
|
|||||||
))
|
))
|
||||||
.tempdir_in(snapshots_dir)?;
|
.tempdir_in(snapshots_dir)?;
|
||||||
|
|
||||||
Self::new_snapshot_package(
|
Self::new(
|
||||||
bank,
|
bank,
|
||||||
bank_snapshot_info,
|
bank_snapshot_info,
|
||||||
status_cache_slot_deltas,
|
status_cache_slot_deltas,
|
||||||
|
Reference in New Issue
Block a user