Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ethcore/snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ 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,
}

impl Default for SnapshotConfiguration {
fn default() -> Self {
SnapshotConfiguration {
no_periodic: false,
enable: false,
processing_threads: ::std::cmp::max(1, num_cpus::get_physical() / 2),
}
}
Expand Down
12 changes: 6 additions & 6 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,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]",
Expand Down Expand Up @@ -1396,7 +1396,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>,
}

Expand Down Expand Up @@ -1913,7 +1913,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,

// -- Light options.
Expand Down Expand Up @@ -2178,7 +2178,7 @@ mod tests {
on_demand_request_consecutive_failures: Some(1),
}),
snapshots: Some(Snapshots {
disable_periodic: Some(true),
enable: Some(false),
processing_threads: None,
}),
misc: Some(Misc {
Expand Down
2 changes: 1 addition & 1 deletion parity/cli/tests/config.full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ on_demand_request_backoff_rounds_max = 100
on_demand_request_consecutive_failures = 1

[snapshots]
disable_periodic = false
enable = false

[misc]
logging = "own_tx=trace"
Expand Down
2 changes: 1 addition & 1 deletion parity/cli/tests/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ on_demand_request_backoff_rounds_max = 10
on_demand_request_consecutive_failures = 1

[snapshots]
disable_periodic = true
enable = false

[misc]
logging = "own_tx=trace"
Expand Down
2 changes: 1 addition & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ impl Configuration {

fn snapshot_config(&self) -> Result<SnapshotConfiguration, String> {
let mut conf = SnapshotConfiguration::default();
conf.no_periodic = self.args.flag_no_periodic_snapshot;
conf.enable = self.args.flag_enable_snapshotting;
if let Some(threads) = self.args.arg_snapshot_threads {
if threads > 0 {
conf.processing_threads = threads;
Expand Down
28 changes: 13 additions & 15 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,21 +800,19 @@ fn execute_impl<Cr, Rr>(
});

// the watcher must be kept alive.
let watcher = match cmd.snapshot_conf.no_periodic {
true => None,
false => {
let sync = sync_provider.clone();
let watcher = Arc::new(snapshot::Watcher::new(
service.client(),
move || sync.is_major_syncing(),
service.io().channel(),
SNAPSHOT_PERIOD,
SNAPSHOT_HISTORY,
));

service.add_notify(watcher.clone());
Some(watcher)
},
let mut watcher = None;
if cmd.snapshot_conf.enable {
let sync = sync_provider.clone();
let w = Arc::new(snapshot::Watcher::new(
service.client(),
move || sync.is_major_syncing(),
service.io().channel(),
SNAPSHOT_PERIOD,
SNAPSHOT_HISTORY,
));

service.add_notify(w.clone());
watcher = Some(w);
};

client.set_exit_handler(on_client_rq);
Expand Down