Stop authoring blocks when offline (#1655)

* Don't author blocks when offline

* Increased canonicalization delay

* Fixed test
This commit is contained in:
Arkadiy Paronyan
2019-02-01 17:17:53 +01:00
committed by Gav Wood
parent 2155e44e13
commit 641bb7cb46
7 changed files with 26 additions and 2 deletions
@@ -88,6 +88,9 @@ pub trait SyncOracle {
/// Whether the synchronization service is undergoing major sync.
/// Returns true if so.
fn is_major_syncing(&self) -> bool;
/// Whether the synchronization service is offline.
/// Returns true if so.
fn is_offline(&self) -> bool;
}
/// A synchronization oracle for when there is no network.
@@ -96,10 +99,14 @@ pub struct NoNetwork;
impl SyncOracle for NoNetwork {
fn is_major_syncing(&self) -> bool { false }
fn is_offline(&self) -> bool { false }
}
impl<T: SyncOracle> SyncOracle for Arc<T> {
fn is_major_syncing(&self) -> bool {
T::is_major_syncing(&*self)
}
fn is_offline(&self) -> bool {
T::is_offline(&*self)
}
}