keep snapshot watcher alive
This commit is contained in:
parent
2bf235e226
commit
f0ef5e6943
@ -275,6 +275,13 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete the temporary snapshot dir if it does exist.
|
||||||
|
if let Err(e) = fs::remove_dir_all(service.temp_snapshot_dir()) {
|
||||||
|
if e.kind() != ErrorKind {
|
||||||
|
return Err(e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(service)
|
Ok(service)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ impl Broadcast for IoChannel<ClientIoMessage> {
|
|||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
trace!(target: "snapshot_watcher", "broadcast: {}", num);
|
||||||
|
|
||||||
if let Err(e) = self.send(ClientIoMessage::TakeSnapshot(num)) {
|
if let Err(e) = self.send(ClientIoMessage::TakeSnapshot(num)) {
|
||||||
warn!("Snapshot watcher disconnected from IoService: {}", e);
|
warn!("Snapshot watcher disconnected from IoService: {}", e);
|
||||||
}
|
}
|
||||||
@ -88,6 +90,8 @@ impl ChainNotify for Watcher {
|
|||||||
_: Vec<H256>,
|
_: Vec<H256>,
|
||||||
_duration: u64)
|
_duration: u64)
|
||||||
{
|
{
|
||||||
|
trace!(target: "snapshot_watcher", "{} imported", imported.len());
|
||||||
|
|
||||||
let highest = imported.into_iter()
|
let highest = imported.into_iter()
|
||||||
.filter_map(|h| self.oracle.to_number(h))
|
.filter_map(|h| self.oracle.to_number(h))
|
||||||
.filter(|&num| num >= self.period + self.history)
|
.filter(|&num| num >= self.period + self.history)
|
||||||
|
@ -257,6 +257,22 @@ 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");
|
||||||
|
|
||||||
|
// the watcher must be kept alive.
|
||||||
|
let _watcher = match cmd.no_periodic_snapshot {
|
||||||
|
true => None,
|
||||||
|
false => {
|
||||||
|
let watcher = Arc::new(snapshot::Watcher::new(
|
||||||
|
service.client(),
|
||||||
|
service.io().channel(),
|
||||||
|
SNAPSHOT_PERIOD,
|
||||||
|
SNAPSHOT_HISTORY,
|
||||||
|
));
|
||||||
|
|
||||||
|
service.add_notify(watcher.clone());
|
||||||
|
Some(watcher)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if !cmd.no_periodic_snapshot {
|
if !cmd.no_periodic_snapshot {
|
||||||
let watcher = snapshot::Watcher::new(
|
let watcher = snapshot::Watcher::new(
|
||||||
service.client(),
|
service.client(),
|
||||||
|
Loading…
Reference in New Issue
Block a user