Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support: add lateness trait
  • Loading branch information
andresilva committed Apr 3, 2020
commit 23faff662e6a6baceddeb0af82cbe0177fd7d554
17 changes: 16 additions & 1 deletion frame/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sp_core::u32_trait::Value as U32;
use sp_runtime::{
RuntimeDebug,
ConsensusEngineId, DispatchResult, DispatchError,
traits::{MaybeSerializeDeserialize, AtLeast32Bit, Saturating, TrailingZeroInput, Bounded},
traits::{MaybeSerializeDeserialize, AtLeast32Bit, Saturating, TrailingZeroInput, Bounded, Zero},
};
use crate::dispatch::Parameter;
use crate::storage::StorageMap;
Expand Down Expand Up @@ -1032,6 +1032,21 @@ impl<Output: Decode + Default> Randomness<Output> for () {
}
}

/// Trait to be used by block producing consensus engine modules to determine
/// how late the current block is (e.g. in a slot-based proposal mechanism how
/// many slots were skipped since the previous block).
pub trait Lateness<N> {
/// Returns a generic measure of how late the current block is compared to
/// its parent.
fn lateness(&self) -> N;
}

impl<N: Zero> Lateness<N> for () {
fn lateness(&self) -> N {
Zero::zero()
}
}

/// Implementors of this trait provide information about whether or not some validator has
/// been registered with them. The [Session module](../../pallet_session/index.html) is an implementor.
pub trait ValidatorRegistration<ValidatorId> {
Expand Down