mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Remove CanAuthorWith trait (#12213)
* Remove CanAuthorWith trait CanAuthotWith trait removed. Also all dependencies, parameters, type paramers were removed. This is related to removal of native runtime. * Remove commented code * Fix code formatting * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job
This commit is contained in:
committed by
GitHub
parent
6d0bb1a667
commit
214eb25f87
@@ -56,9 +56,7 @@ use sc_consensus::{
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend};
|
||||
use sp_consensus::{
|
||||
CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle,
|
||||
};
|
||||
use sp_consensus::{Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle};
|
||||
use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID};
|
||||
use sp_core::ExecutionContext;
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
||||
@@ -214,18 +212,17 @@ pub trait PowAlgorithm<B: BlockT> {
|
||||
}
|
||||
|
||||
/// A block importer for PoW.
|
||||
pub struct PowBlockImport<B: BlockT, I, C, S, Algorithm, CAW, CIDP> {
|
||||
pub struct PowBlockImport<B: BlockT, I, C, S, Algorithm, CIDP> {
|
||||
algorithm: Algorithm,
|
||||
inner: I,
|
||||
select_chain: S,
|
||||
client: Arc<C>,
|
||||
create_inherent_data_providers: Arc<CIDP>,
|
||||
check_inherents_after: <<B as BlockT>::Header as HeaderT>::Number,
|
||||
can_author_with: CAW,
|
||||
}
|
||||
|
||||
impl<B: BlockT, I: Clone, C, S: Clone, Algorithm: Clone, CAW: Clone, CIDP> Clone
|
||||
for PowBlockImport<B, I, C, S, Algorithm, CAW, CIDP>
|
||||
impl<B: BlockT, I: Clone, C, S: Clone, Algorithm: Clone, CIDP> Clone
|
||||
for PowBlockImport<B, I, C, S, Algorithm, CIDP>
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@@ -235,12 +232,11 @@ impl<B: BlockT, I: Clone, C, S: Clone, Algorithm: Clone, CAW: Clone, CIDP> Clone
|
||||
client: self.client.clone(),
|
||||
create_inherent_data_providers: self.create_inherent_data_providers.clone(),
|
||||
check_inherents_after: self.check_inherents_after,
|
||||
can_author_with: self.can_author_with.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, I, C, S, Algorithm, CAW, CIDP> PowBlockImport<B, I, C, S, Algorithm, CAW, CIDP>
|
||||
impl<B, I, C, S, Algorithm, CIDP> PowBlockImport<B, I, C, S, Algorithm, CIDP>
|
||||
where
|
||||
B: BlockT,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
|
||||
@@ -248,7 +244,6 @@ where
|
||||
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + BlockOf,
|
||||
C::Api: BlockBuilderApi<B>,
|
||||
Algorithm: PowAlgorithm<B>,
|
||||
CAW: CanAuthorWith<B>,
|
||||
CIDP: CreateInherentDataProviders<B, ()>,
|
||||
{
|
||||
/// Create a new block import suitable to be used in PoW
|
||||
@@ -259,7 +254,6 @@ where
|
||||
check_inherents_after: <<B as BlockT>::Header as HeaderT>::Number,
|
||||
select_chain: S,
|
||||
create_inherent_data_providers: CIDP,
|
||||
can_author_with: CAW,
|
||||
) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
@@ -268,7 +262,6 @@ where
|
||||
check_inherents_after,
|
||||
select_chain,
|
||||
create_inherent_data_providers: Arc::new(create_inherent_data_providers),
|
||||
can_author_with,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,16 +276,6 @@ where
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
if let Err(e) = self.can_author_with.can_author_with(&block_id) {
|
||||
debug!(
|
||||
target: "pow",
|
||||
"Skipping `check_inherents` as authoring version is not compatible: {}",
|
||||
e,
|
||||
);
|
||||
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let inherent_data = inherent_data_providers
|
||||
.create_inherent_data()
|
||||
.map_err(|e| Error::CreateInherents(e))?;
|
||||
@@ -317,8 +300,7 @@ where
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<B, I, C, S, Algorithm, CAW, CIDP> BlockImport<B>
|
||||
for PowBlockImport<B, I, C, S, Algorithm, CAW, CIDP>
|
||||
impl<B, I, C, S, Algorithm, CIDP> BlockImport<B> for PowBlockImport<B, I, C, S, Algorithm, CIDP>
|
||||
where
|
||||
B: BlockT,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
|
||||
@@ -328,7 +310,6 @@ where
|
||||
C::Api: BlockBuilderApi<B>,
|
||||
Algorithm: PowAlgorithm<B> + Send + Sync,
|
||||
Algorithm::Difficulty: 'static + Send,
|
||||
CAW: CanAuthorWith<B> + Send + Sync,
|
||||
CIDP: CreateInherentDataProviders<B, ()> + Send + Sync,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
@@ -512,7 +493,7 @@ where
|
||||
///
|
||||
/// `pre_runtime` is a parameter that allows a custom additional pre-runtime digest to be inserted
|
||||
/// for blocks being built. This can encode authorship information, or just be a graffiti.
|
||||
pub fn start_mining_worker<Block, C, S, Algorithm, E, SO, L, CIDP, CAW>(
|
||||
pub fn start_mining_worker<Block, C, S, Algorithm, E, SO, L, CIDP>(
|
||||
block_import: BoxBlockImport<Block, sp_api::TransactionFor<C, Block>>,
|
||||
client: Arc<C>,
|
||||
select_chain: S,
|
||||
@@ -524,7 +505,6 @@ pub fn start_mining_worker<Block, C, S, Algorithm, E, SO, L, CIDP, CAW>(
|
||||
create_inherent_data_providers: CIDP,
|
||||
timeout: Duration,
|
||||
build_time: Duration,
|
||||
can_author_with: CAW,
|
||||
) -> (
|
||||
MiningHandle<Block, Algorithm, C, L, <E::Proposer as Proposer<Block>>::Proof>,
|
||||
impl Future<Output = ()>,
|
||||
@@ -541,7 +521,6 @@ where
|
||||
SO: SyncOracle + Clone + Send + Sync + 'static,
|
||||
L: sc_consensus::JustificationSyncLink<Block>,
|
||||
CIDP: CreateInherentDataProviders<Block, ()>,
|
||||
CAW: CanAuthorWith<Block> + Clone + Send + 'static,
|
||||
{
|
||||
let mut timer = UntilImportedOrTimeout::new(client.import_notification_stream(), timeout);
|
||||
let worker = MiningHandle::new(algorithm.clone(), block_import, justification_sync_link);
|
||||
@@ -573,16 +552,6 @@ where
|
||||
};
|
||||
let best_hash = best_header.hash();
|
||||
|
||||
if let Err(err) = can_author_with.can_author_with(&BlockId::Hash(best_hash)) {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Skipping proposal `can_author_with` returned: {} \
|
||||
Probably a node update is required!",
|
||||
err,
|
||||
);
|
||||
continue
|
||||
}
|
||||
|
||||
if worker.best_hash() == Some(best_hash) {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user