add a current_epoch to BabeApi (#7789)

* add a `current_epoch` to BabeApi

* add current_epoch_start back again

* fix node-runtime

* bump spec version
This commit is contained in:
Robert Habermeier
2020-12-26 19:34:39 -05:00
committed by GitHub
parent 6dfad0921b
commit 9164cde499
4 changed files with 45 additions and 4 deletions
@@ -350,6 +350,21 @@ impl OpaqueKeyOwnershipProof {
}
}
/// BABE epoch information
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct Epoch {
/// The epoch index.
pub epoch_index: u64,
/// The starting slot of the epoch.
pub start_slot: SlotNumber,
/// The duration of this epoch.
pub duration: SlotNumber,
/// The authorities and their weights.
pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
/// Randomness for this epoch.
pub randomness: [u8; VRF_OUTPUT_LENGTH],
}
sp_api::decl_runtime_apis! {
/// API necessary for block authorship with BABE.
#[api_version(2)]
@@ -364,6 +379,9 @@ sp_api::decl_runtime_apis! {
/// Returns the slot number that started the current epoch.
fn current_epoch_start() -> SlotNumber;
/// Returns information regarding the current epoch.
fn current_epoch() -> Epoch;
/// Generates a proof of key ownership for the given authority in the
/// current epoch. An example usage of this module is coupled with the
/// session historical module to prove that a given authority key is