Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ pub struct FrontierBlockImport<B: BlockT, I, C> {
_marker: PhantomData<B>,
}

impl<Block: BlockT, I: Clone + BlockImport<Block>, C> Clone for FrontierBlockImport<Block, I, C> {
fn clone(&self) -> Self {
FrontierBlockImport {
inner: self.inner.clone(),
client: self.client.clone(),
_marker: PhantomData,
}
}
}

impl<B, I, C> FrontierBlockImport<B, I, C> where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
Expand Down
23 changes: 16 additions & 7 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;

pub enum ConsensusResult {
GrandPa((
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
Aura((
sc_consensus_aura::AuraBlockImport<
Block,
FullClient,
FrontierBlockImport<
Block,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
FullClient
>,
AuraPair
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>
)),
ManualSeal
Expand Down Expand Up @@ -90,7 +99,7 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result<

let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import,
aura_block_import.clone(),
Some(Box::new(grandpa_block_import.clone())),
None,
client.clone(),
Expand All @@ -103,7 +112,7 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result<
Ok(sc_service::PartialComponents {
client, backend, task_manager, import_queue, keystore, select_chain, transaction_pool,
inherent_data_providers,
other: ConsensusResult::GrandPa((grandpa_block_import, grandpa_link))
other: ConsensusResult::Aura((aura_block_import, grandpa_link))
})
}

Expand All @@ -129,7 +138,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result<TaskManager,
finality_proof_provider: None,
})?
},
ConsensusResult::GrandPa((_, _)) => {
ConsensusResult::Aura((_, _)) => {
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
Expand Down Expand Up @@ -217,7 +226,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result<TaskManager,
}
log::info!("Manual Seal Ready");
},
ConsensusResult::GrandPa((grandpa_block_import, grandpa_link)) => {
ConsensusResult::Aura((aura_block_import, grandpa_link)) => {
if role.is_authority() {
let proposer = sc_basic_authorship::ProposerFactory::new(
client.clone(),
Expand All @@ -231,7 +240,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result<TaskManager,
sc_consensus_aura::slot_duration(&*client)?,
client.clone(),
select_chain,
grandpa_block_import,
aura_block_import,
proposer,
network.clone(),
inherent_data_providers.clone(),
Expand Down