mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 00:11:01 +00:00
consensus-slots: cleanup SlotDuration config (#10878)
* consensus-slots: cleanup the SlotDuration config * fix tests * address review comments
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
//! Inherents for BABE
|
||||
|
||||
use sp_inherents::{Error, InherentData, InherentIdentifier};
|
||||
|
||||
use sp_std::result::Result;
|
||||
|
||||
/// The BABE inherent identifier.
|
||||
@@ -60,12 +59,11 @@ impl InherentDataProvider {
|
||||
|
||||
/// Creates the inherent data provider by calculating the slot from the given
|
||||
/// `timestamp` and `duration`.
|
||||
pub fn from_timestamp_and_duration(
|
||||
pub fn from_timestamp_and_slot_duration(
|
||||
timestamp: sp_timestamp::Timestamp,
|
||||
duration: std::time::Duration,
|
||||
slot_duration: sp_consensus_slots::SlotDuration,
|
||||
) -> Self {
|
||||
let slot =
|
||||
InherentType::from((timestamp.as_duration().as_millis() / duration.as_millis()) as u64);
|
||||
let slot = InherentType::from_timestamp(timestamp, slot_duration);
|
||||
|
||||
Self { slot }
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ pub const MEDIAN_ALGORITHM_CARDINALITY: usize = 1200; // arbitrary suggestion by
|
||||
/// The index of an authority.
|
||||
pub type AuthorityIndex = u32;
|
||||
|
||||
pub use sp_consensus_slots::Slot;
|
||||
pub use sp_consensus_slots::{Slot, SlotDuration};
|
||||
|
||||
/// An equivocation proof for multiple block authorships on the same slot (i.e. double vote).
|
||||
pub type EquivocationProof<H> = sp_consensus_slots::EquivocationProof<H, AuthorityId>;
|
||||
@@ -237,13 +237,6 @@ impl AllowedSlots {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl sp_consensus::SlotData for BabeGenesisConfiguration {
|
||||
fn slot_duration(&self) -> std::time::Duration {
|
||||
std::time::Duration::from_millis(self.slot_duration)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration data used by the BABE consensus engine.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
|
||||
Reference in New Issue
Block a user