1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use codec::Codec;
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
use sc_consensus_aura::AuraVerifier;
use sc_consensus_slots::InherentDataProviderExt;
use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
use std::{fmt::Debug, hash::Hash, sync::Arc};
use substrate_prometheus_endpoint::Registry;
pub struct ImportQueueParams<'a, I, C, CIDP, S, CAW> {
pub block_import: I,
pub client: Arc<C>,
pub create_inherent_data_providers: CIDP,
pub spawner: &'a S,
pub registry: Option<&'a Registry>,
pub can_author_with: CAW,
pub telemetry: Option<TelemetryHandle>,
}
pub fn import_queue<'a, P, Block, I, C, S, CAW, CIDP>(
ImportQueueParams {
block_import,
client,
create_inherent_data_providers,
spawner,
registry,
can_author_with,
telemetry,
}: ImportQueueParams<'a, I, C, CIDP, S, CAW>,
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
where
Block: BlockT,
C::Api: BlockBuilderApi<Block> + AuraApi<Block, P::Public> + ApiExt<Block>,
C: 'static
+ ProvideRuntimeApi<Block>
+ BlockOf
+ Send
+ Sync
+ AuxStore
+ UsageProvider<Block>
+ HeaderBackend<Block>,
I: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<C, Block>>
+ Send
+ Sync
+ 'static,
P: Pair + Send + Sync + 'static,
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Codec,
P::Signature: Codec,
S: sp_core::traits::SpawnEssentialNamed,
CAW: CanAuthorWith<Block> + Send + Sync + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
sc_consensus_aura::import_queue::<P, _, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
block_import: cumulus_client_consensus_common::ParachainBlockImport::new(block_import),
justification_import: None,
client,
create_inherent_data_providers,
spawner,
registry,
can_author_with,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
telemetry,
})
}
pub struct BuildVerifierParams<C, CIDP, CAW> {
pub client: Arc<C>,
pub create_inherent_data_providers: CIDP,
pub can_author_with: CAW,
pub telemetry: Option<TelemetryHandle>,
}
pub fn build_verifier<P, C, CIDP, CAW>(
BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
telemetry,
}: BuildVerifierParams<C, CIDP, CAW>,
) -> AuraVerifier<C, P, CAW, CIDP> {
sc_consensus_aura::build_verifier(sc_consensus_aura::BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
telemetry,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
})
}