Aura: Remove unused structures and adds SlotDuration::get() (#1565)

This commit is contained in:
Bastian Köcher
2019-01-25 11:56:46 +01:00
committed by Gav Wood
parent 27a882bfac
commit b187695af7
6 changed files with 17 additions and 35 deletions
@@ -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;
}
}
+5 -1
View File
@@ -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.
+1 -2
View File
@@ -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<Block> for Runtime {
impl consensus_aura::AuraApi<Block> for Runtime {
fn slot_duration() -> u64 { 1 }
}
}
+1 -2
View File
@@ -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<Block> for Runtime {
impl consensus_aura::AuraApi<Block> for Runtime {
fn slot_duration() -> u64 {
Aura::slot_duration()
}