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
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<String>,
pub flag_jitvm: bool,
pub flag_log_file: Option<String>,

View File

@ -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,
}));
}

View File

@ -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 {