mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 05:47:58 +00:00
support: add lateness trait (#5519)
* support: add lateness trait * babe: implement the lateness trait * babe: add docs about lateness entry lifetime * babe: don't use option for lateness storage entry
This commit is contained in:
@@ -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;
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user