Aura and Slots refactoring (#8386)

* Make slot duration being exposed as `Duration` to the outside

* Some slot info love

* Add `build_aura_worker` utility function

* Copy copy copy
This commit is contained in:
Bastian Köcher
2021-03-18 00:25:58 +01:00
committed by GitHub
parent 0d6884b919
commit 15e15e7d8e
17 changed files with 188 additions and 68 deletions
+8 -2
View File
@@ -23,6 +23,7 @@ use codec::{Encode, Decode};
#[cfg(feature = "std")]
use sp_inherents::ProvideInherentData;
use sp_inherents::{InherentIdentifier, IsFatalError, InherentData};
use sp_std::time::Duration;
use sp_runtime::RuntimeString;
@@ -43,6 +44,11 @@ impl Timestamp {
pub const fn new(inner: u64) -> Self {
Self(inner)
}
/// Returns `self` as [`Duration`].
pub fn as_duration(&self) -> Duration {
Duration::from_millis(self.0)
}
}
impl sp_std::ops::Deref for Timestamp {
@@ -100,8 +106,8 @@ impl From<Timestamp> for u64 {
}
}
impl From<sp_std::time::Duration> for Timestamp {
fn from(duration: sp_std::time::Duration) -> Self {
impl From<Duration> for Timestamp {
fn from(duration: Duration) -> Self {
Timestamp(duration.as_millis() as u64)
}
}