mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
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:
@@ -55,13 +55,13 @@ impl BabeInherentData for InherentData {
|
||||
// TODO: Remove in the future. https://github.com/paritytech/substrate/issues/8029
|
||||
#[cfg(feature = "std")]
|
||||
pub struct InherentDataProvider {
|
||||
slot_duration: u64,
|
||||
slot_duration: std::time::Duration,
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl InherentDataProvider {
|
||||
/// Constructs `Self`
|
||||
pub fn new(slot_duration: u64) -> Self {
|
||||
pub fn new(slot_duration: std::time::Duration) -> Self {
|
||||
Self { slot_duration }
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ impl ProvideInherentData for InherentDataProvider {
|
||||
|
||||
fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> {
|
||||
let timestamp = inherent_data.timestamp_inherent_data()?;
|
||||
let slot = *timestamp / self.slot_duration;
|
||||
let slot = *timestamp / self.slot_duration.as_millis() as u64;
|
||||
inherent_data.put_data(INHERENT_IDENTIFIER, &slot)
|
||||
}
|
||||
|
||||
|
||||
@@ -242,8 +242,8 @@ impl AllowedSlots {
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl sp_consensus::SlotData for BabeGenesisConfiguration {
|
||||
fn slot_duration(&self) -> u64 {
|
||||
self.slot_duration
|
||||
fn slot_duration(&self) -> std::time::Duration {
|
||||
std::time::Duration::from_millis(self.slot_duration)
|
||||
}
|
||||
|
||||
const SLOT_KEY: &'static [u8] = b"babe_configuration";
|
||||
|
||||
Reference in New Issue
Block a user