diff --git a/substrate/core/consensus/aura/primitives/src/lib.rs b/substrate/core/consensus/aura/primitives/src/lib.rs index c37677283f..27f9a123bc 100644 --- a/substrate/core/consensus/aura/primitives/src/lib.rs +++ b/substrate/core/consensus/aura/primitives/src/lib.rs @@ -18,36 +18,16 @@ #![cfg_attr(not(feature = "std"), no_std)] -/// The ApiIds for Aura authorship API. -pub mod id { - use substrate_client::runtime_api::ApiId; +use substrate_client::decl_runtime_apis; - /// ApiId for the AuraApi trait. - pub const AURA_API: ApiId = *b"aura_api"; -} - -/// Aura consensus environmental data. Useful for block-proposing code. -pub struct AuraConsensusData { - /// The timestamp the block should be authored with. - pub timestamp: u64, - /// The slot number. - pub slot: u64, - /// The duration of the slot, in seconds. - pub slot_duration: u64, -} - -/// Runtime-APIs -pub mod api { - use substrate_client::decl_runtime_apis; - decl_runtime_apis! { - /// API necessary for block authorship with aura. - pub trait AuraApi { - /// Return the slot duration in seconds for Aura. - /// Currently, only the value provided by this type at genesis - /// will be used. - /// - /// Dynamic slot duration may be supported in the future. - fn slot_duration() -> u64; - } +decl_runtime_apis! { + /// API necessary for block authorship with aura. + pub trait AuraApi { + /// Return the slot duration in seconds for Aura. + /// Currently, only the value provided by this type at genesis + /// will be used. + /// + /// Dynamic slot duration may be supported in the future. + fn slot_duration() -> u64; } } diff --git a/substrate/core/consensus/aura/src/lib.rs b/substrate/core/consensus/aura/src/lib.rs index f3ab407dce..8030713e56 100644 --- a/substrate/core/consensus/aura/src/lib.rs +++ b/substrate/core/consensus/aura/src/lib.rs @@ -47,7 +47,6 @@ use inherents::{InherentDataProviders, InherentData, RuntimeString}; use futures::{Stream, Future, IntoFuture, future::{self, Either}}; use tokio::timer::Timeout; -use api::AuraApi; use slots::Slots; use ::log::{warn, debug, log, info, trace}; @@ -632,6 +631,11 @@ impl SlotDuration { } } } + + /// Returns slot duration value. + pub fn get(&self) -> u64 { + self.0 + } } /// Register the aura inherent data provider, if not registered already. diff --git a/substrate/core/test-runtime/src/lib.rs b/substrate/core/test-runtime/src/lib.rs index e60025de31..1fa263670a 100644 --- a/substrate/core/test-runtime/src/lib.rs +++ b/substrate/core/test-runtime/src/lib.rs @@ -67,7 +67,6 @@ pub use primitives::hash::H256; use primitives::{Ed25519AuthorityId, OpaqueMetadata}; #[cfg(any(feature = "std", test))] use runtime_version::NativeVersion; -use consensus_aura::api as aura_api; use inherents::{CheckInherentsResult, InherentData}; /// Test runtime version. @@ -278,7 +277,7 @@ impl_runtime_apis! { } } - impl aura_api::AuraApi for Runtime { + impl consensus_aura::AuraApi for Runtime { fn slot_duration() -> u64 { 1 } } } diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index edede7bdd5..16a56bcade 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index f25a46f267..1bc0b3d912 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -80,7 +80,6 @@ use council::seats as council_seats; #[cfg(any(feature = "std", test))] use version::NativeVersion; use substrate_primitives::OpaqueMetadata; -use consensus_aura::api as aura_api; #[cfg(any(feature = "std", test))] pub use runtime_primitives::BuildStorage; @@ -335,7 +334,7 @@ impl_runtime_apis! { } } - impl aura_api::AuraApi for Runtime { + impl consensus_aura::AuraApi for Runtime { fn slot_duration() -> u64 { Aura::slot_duration() } diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index 25c28b6eb8..d8eedb7468 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ