2021-12-03 09:00:31 -08:00
|
|
|
use {
|
|
|
|
crate::snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
|
|
|
solana_sdk::clock::Slot,
|
|
|
|
std::path::PathBuf,
|
|
|
|
};
|
2021-07-01 06:55:26 -07:00
|
|
|
|
|
|
|
/// Snapshot configuration and runtime information
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct SnapshotConfig {
|
2022-09-02 05:56:23 -07:00
|
|
|
/// Specifies the ways thats snapshots are allowed to be used
|
|
|
|
pub usage: SnapshotUsage,
|
|
|
|
|
2021-08-04 12:40:20 -07:00
|
|
|
/// Generate a new full snapshot archive every this many slots
|
|
|
|
pub full_snapshot_archive_interval_slots: Slot,
|
2021-07-01 06:55:26 -07:00
|
|
|
|
2021-08-04 12:40:20 -07:00
|
|
|
/// Generate a new incremental snapshot archive every this many slots
|
|
|
|
pub incremental_snapshot_archive_interval_slots: Slot,
|
|
|
|
|
2022-05-10 13:37:41 -07:00
|
|
|
/// Path to the directory where full snapshot archives are stored
|
|
|
|
pub full_snapshot_archives_dir: PathBuf,
|
|
|
|
|
|
|
|
/// Path to the directory where incremental snapshot archives are stored
|
|
|
|
pub incremental_snapshot_archives_dir: PathBuf,
|
2021-07-01 06:55:26 -07:00
|
|
|
|
2021-08-21 13:41:03 -07:00
|
|
|
/// Path to the directory where bank snapshots are stored
|
|
|
|
pub bank_snapshots_dir: PathBuf,
|
2021-07-01 06:55:26 -07:00
|
|
|
|
|
|
|
/// The archive format to use for snapshots
|
|
|
|
pub archive_format: ArchiveFormat,
|
|
|
|
|
|
|
|
/// Snapshot version to generate
|
|
|
|
pub snapshot_version: SnapshotVersion,
|
|
|
|
|
2021-08-04 12:40:20 -07:00
|
|
|
/// Maximum number of full snapshot archives to retain
|
2021-09-03 09:28:10 -07:00
|
|
|
pub maximum_full_snapshot_archives_to_retain: usize,
|
2021-09-03 13:21:32 -07:00
|
|
|
|
|
|
|
/// Maximum number of incremental snapshot archives to retain
|
|
|
|
/// NOTE: Incremental snapshots will only be kept for the latest full snapshot
|
|
|
|
pub maximum_incremental_snapshot_archives_to_retain: usize,
|
2021-09-13 06:27:50 -07:00
|
|
|
|
|
|
|
/// This is the `debug_verify` parameter to use when calling `update_accounts_hash()`
|
|
|
|
pub accounts_hash_debug_verify: bool,
|
2021-10-26 18:56:16 -07:00
|
|
|
|
|
|
|
// Thread niceness adjustment for snapshot packager service
|
|
|
|
pub packager_thread_niceness_adj: i8,
|
2021-07-01 06:55:26 -07:00
|
|
|
}
|
2021-09-12 11:44:27 -07:00
|
|
|
|
|
|
|
impl Default for SnapshotConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
2022-09-02 05:56:23 -07:00
|
|
|
usage: SnapshotUsage::LoadAndGenerate,
|
2021-09-12 11:44:27 -07:00
|
|
|
full_snapshot_archive_interval_slots:
|
|
|
|
snapshot_utils::DEFAULT_FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
|
|
|
incremental_snapshot_archive_interval_slots:
|
|
|
|
snapshot_utils::DEFAULT_INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
2022-05-10 13:37:41 -07:00
|
|
|
full_snapshot_archives_dir: PathBuf::default(),
|
|
|
|
incremental_snapshot_archives_dir: PathBuf::default(),
|
2021-09-12 11:44:27 -07:00
|
|
|
bank_snapshots_dir: PathBuf::default(),
|
|
|
|
archive_format: ArchiveFormat::TarBzip2,
|
|
|
|
snapshot_version: SnapshotVersion::default(),
|
|
|
|
maximum_full_snapshot_archives_to_retain:
|
|
|
|
snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
|
|
|
maximum_incremental_snapshot_archives_to_retain:
|
|
|
|
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
2021-09-13 06:27:50 -07:00
|
|
|
accounts_hash_debug_verify: false,
|
2021-10-26 18:56:16 -07:00
|
|
|
packager_thread_niceness_adj: 0,
|
2021-09-12 11:44:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-02 05:56:23 -07:00
|
|
|
|
|
|
|
impl SnapshotConfig {
|
|
|
|
/// A new snapshot config used for only loading at startup
|
|
|
|
#[must_use]
|
|
|
|
pub fn new_load_only() -> Self {
|
|
|
|
Self {
|
|
|
|
usage: SnapshotUsage::LoadOnly,
|
|
|
|
..Self::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Should snapshots be generated?
|
|
|
|
#[must_use]
|
|
|
|
pub fn should_generate_snapshots(&self) -> bool {
|
|
|
|
self.usage == SnapshotUsage::LoadAndGenerate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Specify the ways that snapshots are allowed to be used
|
|
|
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
|
|
|
pub enum SnapshotUsage {
|
|
|
|
/// Snapshots are only used at startup, to load the accounts and bank
|
|
|
|
LoadOnly,
|
|
|
|
/// Snapshots are used everywhere; both at startup (i.e. load) and steady-state (i.e.
|
|
|
|
/// generate). This enables taking snapshots.
|
|
|
|
LoadAndGenerate,
|
|
|
|
}
|