disabling of periodic snapshots with the --no-periodic-snapshot flag

This commit is contained in:
Robert Habermeier 2016-09-02 20:24:59 +02:00
parent d9eb87cae7
commit a0541738ab
3 changed files with 18 additions and 7 deletions

View File

@ -243,6 +243,8 @@ Snapshot Options:
index, hash, or 'latest'. Note that taking snapshots at index, hash, or 'latest'. Note that taking snapshots at
non-recent blocks will only work with --pruning archive non-recent blocks will only work with --pruning archive
[default: latest] [default: latest]
--no-periodic-snapshot Disable automated snapshots which usually occur once
every 10000 blocks.
Virtual Machine Options: Virtual Machine Options:
--jitvm Enable the JIT VM. --jitvm Enable the JIT VM.
@ -382,6 +384,7 @@ pub struct Args {
pub flag_from: String, pub flag_from: String,
pub flag_to: String, pub flag_to: String,
pub flag_at: String, pub flag_at: String,
pub flag_no_periodic_snapshot: bool,
pub flag_format: Option<String>, pub flag_format: Option<String>,
pub flag_jitvm: bool, pub flag_jitvm: bool,
pub flag_log_file: Option<String>, pub flag_log_file: Option<String>,

View File

@ -226,6 +226,7 @@ impl Configuration {
ui: self.args.cmd_ui, ui: self.args.cmd_ui,
name: self.args.flag_identity, name: self.args.flag_identity,
custom_bootnodes: self.args.flag_bootnodes.is_some(), custom_bootnodes: self.args.flag_bootnodes.is_some(),
no_periodic_snapshot: self.args.flag_no_periodic_snapshot,
}; };
Cmd::Run(run_cmd) Cmd::Run(run_cmd)
}; };
@ -802,6 +803,7 @@ mod tests {
ui: false, ui: false,
name: "".into(), name: "".into(),
custom_bootnodes: false, custom_bootnodes: false,
no_periodic_snapshot: false,
})); }));
} }

View File

@ -47,7 +47,10 @@ use rpc_apis;
use rpc; use rpc;
use url; use url;
// how often to take periodic snapshots.
const SNAPSHOT_PERIOD: u64 = 10000; const SNAPSHOT_PERIOD: u64 = 10000;
// how many blocks to wait before starting a periodic snapshot.
const SNAPSHOT_HISTORY: u64 = 1000; const SNAPSHOT_HISTORY: u64 = 1000;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -81,6 +84,7 @@ pub struct RunCmd {
pub ui: bool, pub ui: bool,
pub name: String, pub name: String,
pub custom_bootnodes: bool, pub custom_bootnodes: bool,
pub no_periodic_snapshot: bool,
} }
pub fn execute(cmd: RunCmd) -> Result<(), String> { 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"); service.register_io_handler(io_handler).expect("Error registering IO handler");
let watcher = snapshot::Watcher::new( if !cmd.no_periodic_snapshot {
service.client(), let watcher = snapshot::Watcher::new(
service.io().channel(), service.client(),
SNAPSHOT_PERIOD, service.io().channel(),
SNAPSHOT_HISTORY, SNAPSHOT_PERIOD,
); SNAPSHOT_HISTORY,
);
service.add_notify(Arc::new(watcher)); service.add_notify(Arc::new(watcher));
}
// start ui // start ui
if cmd.ui { if cmd.ui {