consensus-slots: cleanup SlotDuration config (#10878)

* consensus-slots: cleanup the SlotDuration config

* fix tests

* address review comments
This commit is contained in:
André Silva
2022-02-22 19:39:16 +00:00
committed by GitHub
parent f00404bfd6
commit 2561e11ed7
19 changed files with 161 additions and 191 deletions
@@ -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 }
}