mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 06:47:57 +00:00
Check in block authoring that we can author with current authoring version (#4201)
* Check in block authoring that we can author with current authoring version * Update client/consensus/pow/src/lib.rs Co-Authored-By: André Silva <andre.beat@gmail.com> * Fix compilation
This commit is contained in:
@@ -65,7 +65,7 @@ pub use babe_primitives::{
|
||||
pub use consensus_common::SyncOracle;
|
||||
use std::{collections::HashMap, sync::Arc, u64, pin::Pin, time::{Instant, Duration}};
|
||||
use babe_primitives;
|
||||
use consensus_common::ImportResult;
|
||||
use consensus_common::{ImportResult, CanAuthorWith};
|
||||
use consensus_common::import_queue::{
|
||||
BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
@@ -241,7 +241,7 @@ impl std::ops::Deref for Config {
|
||||
}
|
||||
|
||||
/// Parameters for BABE.
|
||||
pub struct BabeParams<B: BlockT, C, E, I, SO, SC> {
|
||||
pub struct BabeParams<B: BlockT, C, E, I, SO, SC, CAW> {
|
||||
/// The keystore that manages the keys of the node.
|
||||
pub keystore: KeyStorePtr,
|
||||
|
||||
@@ -270,10 +270,13 @@ pub struct BabeParams<B: BlockT, C, E, I, SO, SC> {
|
||||
|
||||
/// The source of timestamps for relative slots
|
||||
pub babe_link: BabeLink<B>,
|
||||
|
||||
/// Checks if the current native implementation can author with a runtime at a given block.
|
||||
pub can_author_with: CAW,
|
||||
}
|
||||
|
||||
/// Start the babe worker. The returned future should be run in a tokio runtime.
|
||||
pub fn start_babe<B, C, SC, E, I, SO, Error>(BabeParams {
|
||||
pub fn start_babe<B, C, SC, E, I, SO, CAW, Error>(BabeParams {
|
||||
keystore,
|
||||
client,
|
||||
select_chain,
|
||||
@@ -283,7 +286,8 @@ pub fn start_babe<B, C, SC, E, I, SO, Error>(BabeParams {
|
||||
inherent_data_providers,
|
||||
force_authoring,
|
||||
babe_link,
|
||||
}: BabeParams<B, C, E, I, SO, SC>) -> Result<
|
||||
can_author_with,
|
||||
}: BabeParams<B, C, E, I, SO, SC, CAW>) -> Result<
|
||||
impl futures01::Future<Item=(), Error=()>,
|
||||
consensus_common::Error,
|
||||
> where
|
||||
@@ -298,6 +302,7 @@ pub fn start_babe<B, C, SC, E, I, SO, Error>(BabeParams {
|
||||
I: BlockImport<B,Error=ConsensusError> + Send + Sync + 'static,
|
||||
Error: std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
CAW: CanAuthorWith<B> + Send,
|
||||
{
|
||||
let config = babe_link.config;
|
||||
let worker = BabeWorker {
|
||||
@@ -326,6 +331,7 @@ pub fn start_babe<B, C, SC, E, I, SO, Error>(BabeParams {
|
||||
sync_oracle,
|
||||
inherent_data_providers,
|
||||
babe_link.time_source,
|
||||
can_author_with,
|
||||
);
|
||||
|
||||
Ok(slot_worker.map(|_| Ok::<(), ()>(())).compat())
|
||||
|
||||
@@ -404,6 +404,7 @@ fn run_one_test(
|
||||
force_authoring: false,
|
||||
babe_link: data.link.clone(),
|
||||
keystore,
|
||||
can_author_with: consensus_common::AlwaysCanAuthor,
|
||||
}).expect("Starts babe"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user