srml: babe: add expected block time and epoch duration constants (#3241)

* srml: babe: add expected block time constant

* srml: babe: expose epoch duration constant

* node: bump spec_version

* core: don't use moment type in test-runtime

* babe: add docs regarding c parameter
This commit is contained in:
André Silva
2019-07-30 06:39:33 +01:00
committed by Gavin Wood
parent 20eb52d6bb
commit 483ad60379
5 changed files with 27 additions and 6 deletions
+12
View File
@@ -109,6 +109,7 @@ impl ProvideInherentData for InherentDataProvider {
pub trait Trait: timestamp::Trait {
type EpochDuration: Get<u64>;
type ExpectedBlockTime: Get<Self::Moment>;
}
/// The length of the BABE randomness
@@ -156,6 +157,17 @@ decl_storage! {
decl_module! {
/// The BABE SRML module
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// The number of **slots** that an epoch takes. We couple sessions to
/// epochs, i.e. we start a new session once the new epoch begins.
const EpochDuration: u64 = T::EpochDuration::get();
/// The expected average block time at which BABE should be creating
/// blocks. Since BABE is probabilistic it is not trivial to figure out
/// what the expected average block time should be based on the slot
/// duration and the security parameter `c` (where `1 - c` represents
/// the probability of a slot being empty).
const ExpectedBlockTime: T::Moment = T::ExpectedBlockTime::get();
/// Initialization
fn on_initialize() {
for digest in Self::get_inherent_digests()