mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 03:17:56 +00:00
SlotDuration: Always fetch the slot duration from the runtime (#10509)
* SlotDuration: Always fetch the slot duration from the runtime The slot duration should always be fetched from the runtime instead of being cached in the db. The slot duration is only fetched on startup of the node, so the performance isn't that important. This is especially helpful for the case when the slot duration of a chain should be changed through a runtime upgrade (there be dragons, so take care). * Fix docs * Remove logging * Fix warning
This commit is contained in:
@@ -85,7 +85,7 @@ type AuthorityId<P> = <P as Pair>::Public;
|
||||
/// Slot duration type for Aura.
|
||||
pub type SlotDuration = sc_consensus_slots::SlotDuration<sp_consensus_aura::SlotDuration>;
|
||||
|
||||
/// Get type of `SlotDuration` for Aura.
|
||||
/// Get the slot duration for Aura.
|
||||
pub fn slot_duration<A, B, C>(client: &C) -> CResult<SlotDuration>
|
||||
where
|
||||
A: Codec,
|
||||
@@ -93,7 +93,10 @@ where
|
||||
C: AuxStore + ProvideRuntimeApi<B> + UsageProvider<B>,
|
||||
C::Api: AuraApi<B, A>,
|
||||
{
|
||||
SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b).map_err(Into::into))
|
||||
let best_block_id = BlockId::Hash(client.usage_info().chain.best_hash);
|
||||
let slot_duration = client.runtime_api().slot_duration(&best_block_id)?;
|
||||
|
||||
Ok(SlotDuration::new(slot_duration))
|
||||
}
|
||||
|
||||
/// Get slot author for given block along with authorities.
|
||||
|
||||
Reference in New Issue
Block a user