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
+5
View File
@@ -272,6 +272,11 @@ pub fn start_aura<B, C, E, I, SO, Error>(
}
};
if sync_oracle.is_offline() && authorities.len() > 1 {
debug!(target: "aura", "Skipping proposal slot. Waiting for the netork.");
return Either::B(future::ok(()));
}
let proposal_work = match slot_author(slot_num, &authorities) {
None => return Either::B(future::ok(())),
Some(author) => if author.0 == public_key.0 {
@@ -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)
}
}