2021-07-01 06:55:26 -07:00
|
|
|
use crate::snapshot_utils::{ArchiveFormat, SnapshotVersion};
|
2020-06-17 08:27:03 -07:00
|
|
|
use crate::{accounts_db::SnapshotStorages, bank::BankSlotDelta};
|
2020-02-10 03:11:37 -08:00
|
|
|
use solana_sdk::clock::Slot;
|
2021-03-31 13:39:34 -07:00
|
|
|
use solana_sdk::genesis_config::ClusterType;
|
2020-02-20 11:46:13 -08:00
|
|
|
use solana_sdk::hash::Hash;
|
2020-02-18 09:02:29 -08:00
|
|
|
use std::{
|
|
|
|
path::PathBuf,
|
2020-02-20 22:27:55 -08:00
|
|
|
sync::mpsc::{Receiver, SendError, Sender},
|
2020-02-18 09:02:29 -08:00
|
|
|
};
|
2019-08-07 13:12:53 -07:00
|
|
|
use tempfile::TempDir;
|
2019-07-31 17:58:10 -07:00
|
|
|
|
2021-02-04 07:00:33 -08:00
|
|
|
pub type AccountsPackageSender = Sender<AccountsPackagePre>;
|
|
|
|
pub type AccountsPackageReceiver = Receiver<AccountsPackagePre>;
|
|
|
|
pub type AccountsPackageSendError = SendError<AccountsPackagePre>;
|
2019-07-31 17:58:10 -07:00
|
|
|
|
2020-01-23 08:46:30 -08:00
|
|
|
#[derive(Debug)]
|
2021-02-04 07:00:33 -08:00
|
|
|
pub struct AccountsPackagePre {
|
|
|
|
pub slot: Slot,
|
|
|
|
pub block_height: Slot,
|
|
|
|
pub slot_deltas: Vec<BankSlotDelta>,
|
|
|
|
pub snapshot_links: TempDir,
|
|
|
|
pub storages: SnapshotStorages,
|
|
|
|
pub hash: Hash, // temporarily here while we still have to calculate hash before serializing bank
|
|
|
|
pub archive_format: ArchiveFormat,
|
|
|
|
pub snapshot_version: SnapshotVersion,
|
|
|
|
pub snapshot_output_dir: PathBuf,
|
|
|
|
pub expected_capitalization: u64,
|
|
|
|
pub hash_for_testing: Option<Hash>,
|
2021-03-31 13:39:34 -07:00
|
|
|
pub cluster_type: ClusterType,
|
2021-02-04 07:00:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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>,
|
2021-03-31 13:39:34 -07:00
|
|
|
cluster_type: ClusterType,
|
2021-02-04 07:00:33 -08:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
slot,
|
|
|
|
block_height,
|
|
|
|
slot_deltas,
|
|
|
|
snapshot_links,
|
|
|
|
storages,
|
|
|
|
hash,
|
|
|
|
archive_format,
|
|
|
|
snapshot_version,
|
|
|
|
snapshot_output_dir,
|
|
|
|
expected_capitalization,
|
|
|
|
hash_for_testing,
|
2021-03-31 13:39:34 -07:00
|
|
|
cluster_type,
|
2021-02-04 07:00:33 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 15:12:20 -07:00
|
|
|
pub struct AccountsPackage {
|
2021-01-04 13:22:58 -08:00
|
|
|
pub slot: Slot,
|
2020-04-16 15:12:20 -07:00
|
|
|
pub block_height: Slot,
|
2020-02-10 03:11:37 -08:00
|
|
|
pub slot_deltas: Vec<BankSlotDelta>,
|
2019-10-18 14:58:16 -07:00
|
|
|
pub snapshot_links: TempDir,
|
2020-02-20 22:27:55 -08:00
|
|
|
pub storages: SnapshotStorages,
|
2019-10-18 14:58:16 -07:00
|
|
|
pub tar_output_file: PathBuf,
|
2020-02-20 11:46:13 -08:00
|
|
|
pub hash: Hash,
|
2021-01-07 22:45:42 -08:00
|
|
|
pub archive_format: ArchiveFormat,
|
2020-06-18 22:38:37 -07:00
|
|
|
pub snapshot_version: SnapshotVersion,
|
2019-07-31 17:58:10 -07:00
|
|
|
}
|
|
|
|
|
2020-04-16 15:12:20 -07:00
|
|
|
impl AccountsPackage {
|
2019-07-31 17:58:10 -07:00
|
|
|
pub fn new(
|
2021-01-04 13:22:58 -08:00
|
|
|
slot: Slot,
|
2020-04-16 15:12:20 -07:00
|
|
|
block_height: u64,
|
2020-02-10 03:11:37 -08:00
|
|
|
slot_deltas: Vec<BankSlotDelta>,
|
2019-08-07 13:12:53 -07:00
|
|
|
snapshot_links: TempDir,
|
2020-02-20 22:27:55 -08:00
|
|
|
storages: SnapshotStorages,
|
2019-07-31 17:58:10 -07:00
|
|
|
tar_output_file: PathBuf,
|
2020-02-20 11:46:13 -08:00
|
|
|
hash: Hash,
|
2021-01-07 22:45:42 -08:00
|
|
|
archive_format: ArchiveFormat,
|
2020-06-18 22:38:37 -07:00
|
|
|
snapshot_version: SnapshotVersion,
|
2019-07-31 17:58:10 -07:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
2021-01-04 13:22:58 -08:00
|
|
|
slot,
|
2020-04-16 15:12:20 -07:00
|
|
|
block_height,
|
2019-09-25 13:42:19 -07:00
|
|
|
slot_deltas,
|
2019-08-07 13:12:53 -07:00
|
|
|
snapshot_links,
|
2020-02-20 22:27:55 -08:00
|
|
|
storages,
|
2019-07-31 17:58:10 -07:00
|
|
|
tar_output_file,
|
2020-02-20 11:46:13 -08:00
|
|
|
hash,
|
2021-01-07 22:45:42 -08:00
|
|
|
archive_format,
|
2020-06-18 22:38:37 -07:00
|
|
|
snapshot_version,
|
2019-07-31 17:58:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|