babe: Disable unused median calculation (#3251)

* babe: don't execute median algorithm

* babe: checked sub in median calculation

* node: bump impl_version to make ci happy

* babe: remove forbid dead_code
This commit is contained in:
André Silva
2019-07-30 22:08:20 +01:00
committed by GitHub
parent 1d5cd20c44
commit bd052d8da4
2 changed files with 7 additions and 12 deletions
+6 -11
View File
@@ -19,7 +19,6 @@
//! BABE (Blind Assignment for Blockchain Extension) consensus in Substrate.
#![forbid(unsafe_code, missing_docs, unused_must_use, unused_imports, unused_variables)]
#![cfg_attr(not(test), forbid(dead_code))]
pub use babe_primitives::*;
pub use consensus_common::SyncOracle;
use consensus_common::ImportResult;
@@ -581,6 +580,7 @@ impl<C> BabeVerifier<C> {
}
}
#[allow(dead_code)]
fn median_algorithm(
median_required_blocks: u64,
slot_duration: u64,
@@ -612,8 +612,12 @@ fn median_algorithm(
.get(num_timestamps / 2)
.expect("we have at least one timestamp, so this is a valid index; qed");
let now = Instant::now();
if now >= median {
time_source.0.replace(now - median);
}
time_source.1.clear();
time_source.0.replace(Instant::now() - median);
} else {
time_source.1.push((Instant::now(), slot_now))
}
@@ -706,15 +710,6 @@ impl<B: BlockT, C> Verifier<B> for BabeVerifier<C> where
fork_choice: ForkChoiceStrategy::LongestChain,
};
// FIXME: this should eventually be moved to BabeBlockImport
median_algorithm(
self.config.0.median_required_blocks,
self.config.get(),
slot_number,
slot_now,
&mut *self.time_source.0.lock(),
);
Ok((import_block, Default::default()))
}
CheckedHeader::Deferred(a, b) => {
+1 -1
View File
@@ -80,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 123,
impl_version: 124,
impl_version: 125,
apis: RUNTIME_API_VERSIONS,
};