register the watcher as a ChainNotify

This commit is contained in:
Robert Habermeier 2016-09-02 18:48:07 +02:00
parent e3749b3bc4
commit 1c450f616d

View File

@ -28,6 +28,7 @@ use ethcore::client::{Mode, Switch, DatabaseCompactionProfile, VMType, ChainNoti
use ethcore::service::ClientService; use ethcore::service::ClientService;
use ethcore::account_provider::AccountProvider; use ethcore::account_provider::AccountProvider;
use ethcore::miner::{Miner, MinerService, ExternalMiner, MinerOptions}; use ethcore::miner::{Miner, MinerService, ExternalMiner, MinerOptions};
use ethcore::snapshot;
use ethsync::SyncConfig; use ethsync::SyncConfig;
use informant::Informant; use informant::Informant;
@ -46,6 +47,9 @@ use rpc_apis;
use rpc; use rpc;
use url; use url;
const SNAPSHOT_PERIOD: u64 = 10000;
const SNAPSHOT_HISTORY: u64 = 1000;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct RunCmd { pub struct RunCmd {
pub cache_config: CacheConfig, pub cache_config: CacheConfig,
@ -249,6 +253,15 @@ 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(
service.client(),
service.io().channel(),
SNAPSHOT_PERIOD,
SNAPSHOT_HISTORY,
);
service.add_notify(Arc::new(watcher));
// start ui // start ui
if cmd.ui { if cmd.ui {
if !cmd.dapps_conf.enabled { if !cmd.dapps_conf.enabled {