mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
Aura improvements (#8881)
* Aura: Expose function to build the verifier * Use best block to initialize the authorities cache * Use best block when determining the slot duration * Remove `AuraBlockImport` * Some cleanups * Fix build error
This commit is contained in:
@@ -584,7 +584,7 @@ impl<T: Clone + Send + Sync + 'static> SlotDuration<T> {
|
||||
/// `slot_key` is marked as `'static`, as it should really be a
|
||||
/// compile-time constant.
|
||||
pub fn get_or_compute<B: BlockT, C, CB>(client: &C, cb: CB) -> sp_blockchain::Result<Self> where
|
||||
C: sc_client_api::backend::AuxStore,
|
||||
C: sc_client_api::backend::AuxStore + sc_client_api::UsageProvider<B>,
|
||||
C: ProvideRuntimeApi<B>,
|
||||
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> sp_blockchain::Result<T>,
|
||||
T: SlotData + Encode + Decode + Debug,
|
||||
@@ -599,19 +599,20 @@ impl<T: Clone + Send + Sync + 'static> SlotDuration<T> {
|
||||
})
|
||||
}),
|
||||
None => {
|
||||
use sp_runtime::traits::Zero;
|
||||
let genesis_slot_duration =
|
||||
cb(client.runtime_api(), &BlockId::number(Zero::zero()))?;
|
||||
let best_hash = client.usage_info().chain.best_hash;
|
||||
let slot_duration =
|
||||
cb(client.runtime_api(), &BlockId::hash(best_hash))?;
|
||||
|
||||
info!(
|
||||
"⏱ Loaded block-time = {:?} from genesis on first-launch",
|
||||
genesis_slot_duration.slot_duration()
|
||||
"⏱ Loaded block-time = {:?} from block {:?}",
|
||||
slot_duration.slot_duration(),
|
||||
best_hash,
|
||||
);
|
||||
|
||||
genesis_slot_duration
|
||||
slot_duration
|
||||
.using_encoded(|s| client.insert_aux(&[(T::SLOT_KEY, &s[..])], &[]))?;
|
||||
|
||||
Ok(SlotDuration(genesis_slot_duration))
|
||||
Ok(SlotDuration(slot_duration))
|
||||
}
|
||||
}?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user