Introduce a Slot type (#7997)

* Introduce a `Slot` type

Instead of having some type definition that only was used in half of the
code or directly using `u64`, this adds a new unit type wrapper `Slot`.
This makes it especially easy for the outside api to know what type is
expected/returned.

* Change epoch duratioC

* rename all instances of slot number to slot

* Make the constructor private

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-01-28 20:44:22 +01:00
committed by GitHub
parent 6c2dd28dfb
commit b6294418f8
34 changed files with 549 additions and 445 deletions
+5 -5
View File
@@ -61,7 +61,7 @@ use sp_inherents::{CheckInherentsResult, InherentData};
use cfg_if::cfg_if;
// Ensure Babe and Aura use the same crypto to simplify things a bit.
pub use sp_consensus_babe::{AuthorityId, SlotNumber, AllowedSlots};
pub use sp_consensus_babe::{AuthorityId, Slot, AllowedSlots};
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
@@ -739,7 +739,7 @@ cfg_if! {
}
}
fn current_epoch_start() -> sp_consensus_babe::SlotNumber {
fn current_epoch_start() -> Slot {
<pallet_babe::Module<Runtime>>::current_epoch_start()
}
@@ -761,7 +761,7 @@ cfg_if! {
}
fn generate_key_ownership_proof(
_slot_number: sp_consensus_babe::SlotNumber,
_slot: sp_consensus_babe::Slot,
_authority_id: sp_consensus_babe::AuthorityId,
) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
None
@@ -998,7 +998,7 @@ cfg_if! {
}
}
fn current_epoch_start() -> sp_consensus_babe::SlotNumber {
fn current_epoch_start() -> Slot {
<pallet_babe::Module<Runtime>>::current_epoch_start()
}
@@ -1020,7 +1020,7 @@ cfg_if! {
}
fn generate_key_ownership_proof(
_slot_number: sp_consensus_babe::SlotNumber,
_slot: sp_consensus_babe::Slot,
_authority_id: sp_consensus_babe::AuthorityId,
) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
None