Skip to content

Commit

Permalink
Correct RuntimeApi & RuntimeExecutor (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiguantong authored Dec 20, 2022
1 parent 4187b7b commit 02b2ccb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
48 changes: 37 additions & 11 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,17 +594,43 @@ pub fn run() -> Result<()> {
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

service::start_parachain_node(
config,
polkadot_config,
collator_options,
id,
hwbench,
&eth_rpc_config,
)
.await
.map(|r| r.0)
.map_err(Into::into)
return if chain_spec.is_crab() {
service::start_parachain_node::<CrabRuntimeApi, CrabRuntimeExecutor>(
config,
polkadot_config,
collator_options,
id,
hwbench,
&eth_rpc_config,
)
.await
.map(|r| r.0)
.map_err(Into::into)
} else if chain_spec.is_pangolin() {
service::start_parachain_node::<PangolinRuntimeApi, PangolinRuntimeExecutor>(
config,
polkadot_config,
collator_options,
id,
hwbench,
&eth_rpc_config,
)
.await
.map(|r| r.0)
.map_err(Into::into)
} else {
service::start_parachain_node::<DarwiniaRuntimeApi, DarwiniaRuntimeExecutor>(
config,
polkadot_config,
collator_options,
id,
hwbench,
&eth_rpc_config,
)
.await
.map(|r| r.0)
.map_err(Into::into)
};
})
},
}
Expand Down
24 changes: 14 additions & 10 deletions node/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ where
}

/// Start a parachain node.
pub async fn start_parachain_node(
pub async fn start_parachain_node<RuntimeApi, Executor>(
parachain_config: sc_service::Configuration,
polkadot_config: sc_service::Configuration,
collator_options: cumulus_client_cli::CollatorOptions,
Expand All @@ -533,15 +533,19 @@ pub async fn start_parachain_node(
eth_rpc_config: &crate::cli::EthRpcConfig,
) -> sc_service::error::Result<(
sc_service::TaskManager,
Arc<
sc_service::TFullClient<
Block,
darwinia_runtime::RuntimeApi,
sc_executor::NativeElseWasmExecutor<DarwiniaRuntimeExecutor>,
>,
>,
)> {
start_node_impl::<darwinia_runtime::RuntimeApi, DarwiniaRuntimeExecutor, _, _>(
Arc<sc_service::TFullClient<Block, RuntimeApi, sc_executor::NativeElseWasmExecutor<Executor>>>,
)>
where
RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi<Block, AuraId>,
Executor: 'static + sc_executor::NativeExecutionDispatch,
{
start_node_impl::<RuntimeApi, Executor, _, _>(
parachain_config,
polkadot_config,
collator_options,
Expand Down

0 comments on commit 02b2ccb

Please sign in to comment.