From a0541738aba2792a6eaf50af563946be32fc7408 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 2 Sep 2016 20:24:59 +0200 Subject: [PATCH] disabling of periodic snapshots with the --no-periodic-snapshot flag --- parity/cli.rs | 3 +++ parity/configuration.rs | 2 ++ parity/run.rs | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/parity/cli.rs b/parity/cli.rs index 8f33489dc..91b9c1620 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -243,6 +243,8 @@ Snapshot Options: index, hash, or 'latest'. Note that taking snapshots at non-recent blocks will only work with --pruning archive [default: latest] + --no-periodic-snapshot Disable automated snapshots which usually occur once + every 10000 blocks. Virtual Machine Options: --jitvm Enable the JIT VM. @@ -382,6 +384,7 @@ pub struct Args { pub flag_from: String, pub flag_to: String, pub flag_at: String, + pub flag_no_periodic_snapshot: bool, pub flag_format: Option, pub flag_jitvm: bool, pub flag_log_file: Option, diff --git a/parity/configuration.rs b/parity/configuration.rs index f2fd34853..51d637580 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -226,6 +226,7 @@ impl Configuration { ui: self.args.cmd_ui, name: self.args.flag_identity, custom_bootnodes: self.args.flag_bootnodes.is_some(), + no_periodic_snapshot: self.args.flag_no_periodic_snapshot, }; Cmd::Run(run_cmd) }; @@ -802,6 +803,7 @@ mod tests { ui: false, name: "".into(), custom_bootnodes: false, + no_periodic_snapshot: false, })); } diff --git a/parity/run.rs b/parity/run.rs index 2d619d350..d384a3a7c 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -47,7 +47,10 @@ use rpc_apis; use rpc; use url; +// how often to take periodic snapshots. const SNAPSHOT_PERIOD: u64 = 10000; + +// how many blocks to wait before starting a periodic snapshot. const SNAPSHOT_HISTORY: u64 = 1000; #[derive(Debug, PartialEq)] @@ -81,6 +84,7 @@ pub struct RunCmd { pub ui: bool, pub name: String, pub custom_bootnodes: bool, + pub no_periodic_snapshot: bool, } pub fn execute(cmd: RunCmd) -> Result<(), String> { @@ -253,14 +257,16 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> { }); service.register_io_handler(io_handler).expect("Error registering IO handler"); - let watcher = snapshot::Watcher::new( - service.client(), - service.io().channel(), - SNAPSHOT_PERIOD, - SNAPSHOT_HISTORY, - ); + if !cmd.no_periodic_snapshot { + let watcher = snapshot::Watcher::new( + service.client(), + service.io().channel(), + SNAPSHOT_PERIOD, + SNAPSHOT_HISTORY, + ); - service.add_notify(Arc::new(watcher)); + service.add_notify(Arc::new(watcher)); + } // start ui if cmd.ui {