No snapshotting by default (#11814)

This commit is contained in:
adria0.eth 2020-09-15 16:51:49 +02:00 committed by GitHub
parent 61e56aba41
commit b54ddd027d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 15 deletions

View File

@ -102,8 +102,8 @@ const MAX_SNAPSHOT_SUBPARTS: usize = 256;
/// Configuration for the Snapshot service
#[derive(Debug, Clone, PartialEq)]
pub struct SnapshotConfiguration {
/// If `true`, no periodic snapshots will be created
pub no_periodic: bool,
/// Enable creation of periodic snapshots
pub enable: bool,
/// Number of threads for creating snapshots
pub processing_threads: usize,
}
@ -111,7 +111,7 @@ pub struct SnapshotConfiguration {
impl Default for SnapshotConfiguration {
fn default() -> Self {
SnapshotConfiguration {
no_periodic: false,
enable: false,
processing_threads: ::std::cmp::max(1, num_cpus::get_physical() / 2),
}
}

View File

@ -795,9 +795,9 @@ usage! {
"Skip block seal check.",
["Snapshot Options"]
FLAG flag_no_periodic_snapshot: (bool) = false, or |c: &Config| c.snapshots.as_ref()?.disable_periodic.clone(),
"--no-periodic-snapshot",
"Disable automated snapshots which usually occur once every 5000 blocks.",
FLAG flag_enable_snapshotting: (bool) = false, or |c: &Config| c.snapshots.as_ref()?.enable.clone(),
"--enable-snapshotting",
"Enable automated snapshots which usually occur once every 5000 blocks.",
ARG arg_snapshot_threads: (Option<usize>) = None, or |c: &Config| c.snapshots.as_ref()?.processing_threads,
"--snapshot-threads=[NUM]",
@ -1012,7 +1012,7 @@ struct Footprint {
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct Snapshots {
disable_periodic: Option<bool>,
enable: Option<bool>,
processing_threads: Option<usize>,
}
@ -1419,7 +1419,7 @@ mod tests {
// -- Snapshot Optons
arg_export_state_at: "latest".into(),
arg_snapshot_at: "latest".into(),
flag_no_periodic_snapshot: false,
flag_enable_snapshotting: false,
arg_snapshot_threads: None,
// -- Internal Options
@ -1609,7 +1609,7 @@ mod tests {
num_verifiers: None,
}),
snapshots: Some(Snapshots {
disable_periodic: Some(true),
enable: Some(false),
processing_threads: None,
}),
misc: Some(Misc {

View File

@ -118,7 +118,7 @@ scale_verifiers = true
num_verifiers = 6
[snapshots]
disable_periodic = false
enable = false
[misc]
logging = "own_tx=trace"

View File

@ -65,7 +65,7 @@ fat_db = "off"
scale_verifiers = false
[snapshots]
disable_periodic = true
enable = false
[misc]
logging = "own_tx=trace"

View File

@ -967,7 +967,7 @@ impl Configuration {
fn snapshot_config(&self) -> Result<SnapshotConfiguration, String> {
let conf = SnapshotConfiguration {
no_periodic: self.args.flag_no_periodic_snapshot,
enable: self.args.flag_enable_snapshotting,
processing_threads: match self.args.arg_snapshot_threads {
Some(threads) if threads > 0 => threads,
_ => ::std::cmp::max(1, num_cpus::get_physical() / 2),

View File

@ -556,9 +556,9 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
});
// the watcher must be kept alive.
let watcher = match cmd.snapshot_conf.no_periodic {
true => None,
false => {
let watcher = match cmd.snapshot_conf.enable {
false => None,
true => {
let sync = sync_provider.clone();
let client = client.clone();
let watcher = Arc::new(snapshot::Watcher::new(