diff --git a/substrate/core/consensus/babe/src/lib.rs b/substrate/core/consensus/babe/src/lib.rs index 4a4261b8dd8a0714c839c12a3fe5645e78e09039..fae6fb3c32f17d722e1c2a1cc38cf86899d0a75b 100644 --- a/substrate/core/consensus/babe/src/lib.rs +++ b/substrate/core/consensus/babe/src/lib.rs @@ -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) => { diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 6be19f02ae0005900017cf18ab2ac7a98eb92b32..af1812f34dd4eba4ac4993a440f8b8a4054af8d0 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -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, };