fn start_node_impl<RuntimeApi, Executor>(
	parachain_config: Configuration,
	collator_key: Arc<CollatorPair>,
	mut polkadot_config: polkadot_collator::Configuration,
	id: polkadot_primitives::v0::Id,
	validator: bool,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
where
	RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
		+ Send
		+ Sync
		+ 'static,
	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
		+ sp_api::Metadata<Block>
		+ sp_session::SessionKeys<Block>
		+ sp_api::ApiExt<
			Block,
			Error = sp_blockchain::Error,
			StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
		> + sp_offchain::OffchainWorkerApi<Block>
		+ sp_block_builder::BlockBuilder<Block>,
	sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
	Executor: sc_executor::NativeExecutionDispatch + 'static,
{
	if matches!(parachain_config.role, Role::Light) {
		return Err("Light client not supported!".into());
	}

	let mut parachain_config = prepare_node_config(parachain_config);

	parachain_config.informant_output_format = OutputFormat {
		enable_color: true,
		prefix: format!("[{}] ", Color::Yellow.bold().paint("Parachain")),
	};
	polkadot_config.informant_output_format = OutputFormat {
		enable_color: true,
		prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
	};

	let params = new_partial::<RuntimeApi, Executor>(&mut parachain_config)?;
	params
		.inherent_data_providers
		.register_provider(sp_timestamp::InherentDataProvider)
		.unwrap();

	let client = params.client.clone();
	let backend = params.backend.clone();
	let block_announce_validator = DelayedBlockAnnounceValidator::new();
	let block_announce_validator_builder = {
		let block_announce_validator = block_announce_validator.clone();
		move |_| Box::new(block_announce_validator) as Box<_>
	};

	let prometheus_registry = parachain_config.prometheus_registry().cloned();
	let transaction_pool = params.transaction_pool.clone();
	let mut task_manager = params.task_manager;
	let import_queue = params.import_queue;
	let (network, network_status_sinks, system_rpc_tx, start_network) =
		sc_service::build_network(sc_service::BuildNetworkParams {
			config: &parachain_config,
			client: client.clone(),
			transaction_pool: transaction_pool.clone(),
			spawn_handle: task_manager.spawn_handle(),
			import_queue,
			on_demand: None,
			block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
			finality_proof_request_builder: None,
			finality_proof_provider: None,
		})?;

	if parachain_config.offchain_worker.enabled {
		sc_service::build_offchain_workers(
			&parachain_config,
			backend.clone(),
			task_manager.spawn_handle(),
			client.clone(),
			network.clone(),
		);
	}

	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
		on_demand: None,
		remote_blockchain: None,
		rpc_extensions_builder: Box::new(|_| ()),
		client: client.clone(),
		transaction_pool: transaction_pool.clone(),
		task_manager: &mut task_manager,
		telemetry_connection_sinks: Default::default(),
		config: parachain_config,
		keystore: params.keystore,
		backend,
		network: network.clone(),
		network_status_sinks,
		system_rpc_tx,
	})?;

	let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));

	if validator {
		let proposer_factory = sc_basic_authorship::ProposerFactory::new(
			client.clone(),
			transaction_pool,
			prometheus_registry.as_ref(),
		);

		let params = StartCollatorParams {
			para_id: id,
			block_import: client.clone(),
			proposer_factory,
			inherent_data_providers: params.inherent_data_providers,
			block_status: client.clone(),
			announce_block,
			client: client.clone(),
			block_announce_validator,
			task_manager: &mut task_manager,
			polkadot_config,
			collator_key,
		};

		start_collator(params)?;
	} else {
		let params = StartFullNodeParams {
			client: client.clone(),
			announce_block,
			polkadot_config,
			collator_key,
			block_announce_validator,
			task_manager: &mut task_manager,
			para_id: id,
		};

		start_full_node(params)?;
	}

	start_network.start_network();

	Ok((task_manager, client))
}
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
///
/// This is the actual implementation that is abstract over the executor and the runtime api.
Start a node with the given parachain `Configuration` and relay chain `Configuration`.
This is the actual implementation that is abstract over the executor and the runtime api.
Start a node with the given parachain ` Configuration ` and relay chain ` Configuration ` . This is the actual implementation that is abstract over the executor and the runtime api .
fn start_node_impl<RuntimeApi, Executor>(
	parachain_config: Configuration,
	collator_key: Arc<CollatorPair>,
	mut polkadot_config: polkadot_collator::Configuration,
	id: polkadot_primitives::v0::Id,
	validator: bool,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
where
	RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
		+ Send
		+ Sync
		+ 'static,
	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
		+ sp_api::Metadata<Block>
		+ sp_session::SessionKeys<Block>
		+ sp_api::ApiExt<
			Block,
			Error = sp_blockchain::Error,
			StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
		> + sp_offchain::OffchainWorkerApi<Block>
		+ sp_block_builder::BlockBuilder<Block>,
	sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
	Executor: sc_executor::NativeExecutionDispatch + 'static,
{
	if matches!(parachain_config.role, Role::Light) {
		return Err("Light client not supported!".into());
	}
	let mut parachain_config = prepare_node_config(parachain_config);
	parachain_config.informant_output_format = OutputFormat {
		enable_color: true,
		prefix: format!("[{}] ", Color::Yellow.bold().paint("Parachain")),
	};
	polkadot_config.informant_output_format = OutputFormat {
		enable_color: true,
		prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
	};
	let params = new_partial::<RuntimeApi, Executor>(&mut parachain_config)?;
	params
		.inherent_data_providers
		.register_provider(sp_timestamp::InherentDataProvider)
		.unwrap();
	let client = params.client.clone();
	let backend = params.backend.clone();
	let block_announce_validator = DelayedBlockAnnounceValidator::new();
	let block_announce_validator_builder = {
		let block_announce_validator = block_announce_validator.clone();
		move |_| Box::new(block_announce_validator) as Box<_>
	};
	let prometheus_registry = parachain_config.prometheus_registry().cloned();
	let transaction_pool = params.transaction_pool.clone();
	let mut task_manager = params.task_manager;
	let import_queue = params.import_queue;
	let (network, network_status_sinks, system_rpc_tx, start_network) =
		sc_service::build_network(sc_service::BuildNetworkParams {
			config: &parachain_config,
			client: client.clone(),
			transaction_pool: transaction_pool.clone(),
			spawn_handle: task_manager.spawn_handle(),
			import_queue,
			on_demand: None,
			block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
			finality_proof_request_builder: None,
			finality_proof_provider: None,
		})?;
	if parachain_config.offchain_worker.enabled {
		sc_service::build_offchain_workers(
			&parachain_config,
			backend.clone(),
			task_manager.spawn_handle(),
			client.clone(),
			network.clone(),
		);
	}
	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
		on_demand: None,
		remote_blockchain: None,
		rpc_extensions_builder: Box::new(|_| ()),
		client: client.clone(),
		transaction_pool: transaction_pool.clone(),
		task_manager: &mut task_manager,
		telemetry_connection_sinks: Default::default(),
		config: parachain_config,
		keystore: params.keystore,
		backend,
		network: network.clone(),
		network_status_sinks,
		system_rpc_tx,
	})?;
	let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
	if validator {
		let proposer_factory = sc_basic_authorship::ProposerFactory::new(
			client.clone(),
			transaction_pool,
			prometheus_registry.as_ref(),
		);
		let params = StartCollatorParams {
			para_id: id,
			block_import: client.clone(),
			proposer_factory,
			inherent_data_providers: params.inherent_data_providers,
			block_status: client.clone(),
			announce_block,
			client: client.clone(),
			block_announce_validator,
			task_manager: &mut task_manager,
			polkadot_config,
			collator_key,
		};
		start_collator(params)?;
	} else {
		let params = StartFullNodeParams {
			client: client.clone(),
			announce_block,
			polkadot_config,
			collator_key,
			block_announce_validator,
			task_manager: &mut task_manager,
			para_id: id,
		};
		start_full_node(params)?;
	}
	start_network.start_network();
	Ok((task_manager, client))
}
fn start_node_impl < RuntimeApi , Executor > ( parachain_config : Configuration , collator_key : Arc < CollatorPair > , mut polkadot_config : polkadot_collator :: Configuration , id : polkadot_primitives :: v0 :: Id , validator : bool , ) -> sc_service :: error :: Result < ( TaskManager , Arc < TFullClient < Block , RuntimeApi , Executor > > ) > where RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , Executor > > + Send + Sync + ' static , RuntimeApi :: RuntimeApi : sp_transaction_pool :: runtime_api :: TaggedTransactionQueue < Block > + sp_api :: Metadata < Block > + sp_session :: SessionKeys < Block > + sp_api :: ApiExt < Block , Error = sp_blockchain :: Error , StateBackend = sc_client_api :: StateBackendFor < TFullBackend < Block > , Block > , > + sp_offchain :: OffchainWorkerApi < Block > + sp_block_builder :: BlockBuilder < Block > , sc_client_api :: StateBackendFor < TFullBackend < Block > , Block > : sp_api :: StateBackend < BlakeTwo256 > , Executor : sc_executor :: NativeExecutionDispatch + ' static , { if matches ! ( parachain_config role Role Light ) { return Err ( " " . into ( ) ) ; } let mut parachain_config = prepare_node_config ( parachain_config ) ; parachain_config . informant_output_format = OutputFormat { enable_color : true , prefix : format ! ( " " Color Yellow bold ( ) paint ( " " ) ) , } ; polkadot_config . informant_output_format = OutputFormat { enable_color : true , prefix : format ! ( " " Color Blue bold ( ) paint ( " " ) ) , } ; let params = new_partial :: < RuntimeApi , Executor > ( & mut parachain_config ) ? ; params . inherent_data_providers . register_provider ( sp_timestamp :: InherentDataProvider ) . unwrap ( ) ; let client = params . client . clone ( ) ; let backend = params . backend . clone ( ) ; let block_announce_validator = DelayedBlockAnnounceValidator :: new ( ) ; let block_announce_validator_builder = { let block_announce_validator = block_announce_validator . clone ( ) ; move | _ | Box :: new ( block_announce_validator ) as Box < _ > } ; let prometheus_registry = parachain_config . prometheus_registry ( ) . cloned ( ) ; let transaction_pool = params . transaction_pool . clone ( ) ; let mut task_manager = params . task_manager ; let import_queue = params . import_queue ; let ( network , network_status_sinks , system_rpc_tx , start_network ) = sc_service :: build_network ( sc_service :: BuildNetworkParams { config : & parachain_config , client : client . clone ( ) , transaction_pool : transaction_pool . clone ( ) , spawn_handle : task_manager . spawn_handle ( ) , import_queue , on_demand : None , block_announce_validator_builder : Some ( Box :: new ( block_announce_validator_builder ) ) , finality_proof_request_builder : None , finality_proof_provider : None , } ) ? ; if parachain_config . offchain_worker . enabled { sc_service :: build_offchain_workers ( & parachain_config , backend . clone ( ) , task_manager . spawn_handle ( ) , client . clone ( ) , network . clone ( ) , ) ; } sc_service :: spawn_tasks ( sc_service :: SpawnTasksParams { on_demand : None , remote_blockchain : None , rpc_extensions_builder : Box :: new ( | _ | ( ) ) , client : client . clone ( ) , transaction_pool : transaction_pool . clone ( ) , task_manager : & mut task_manager , telemetry_connection_sinks : Default :: default ( ) , config : parachain_config , keystore : params . keystore , backend , network : network . clone ( ) , network_status_sinks , system_rpc_tx , } ) ? ; let announce_block = Arc :: new ( move | hash , data | network . announce_block ( hash , data ) ) ; if validator { let proposer_factory = sc_basic_authorship :: ProposerFactory :: new ( client . clone ( ) , transaction_pool , prometheus_registry . as_ref ( ) , ) ; let params = StartCollatorParams { para_id : id , block_import : client . clone ( ) , proposer_factory , inherent_data_providers : params . inherent_data_providers , block_status : client . clone ( ) , announce_block , client : client . clone ( ) , block_announce_validator , task_manager : & mut task_manager , polkadot_config , collator_key , } ; start_collator ( params ) ? ; } else { let params = StartFullNodeParams { client : client . clone ( ) , announce_block , polkadot_config , collator_key , block_announce_validator , task_manager : & mut task_manager , para_id : id , } ; start_full_node ( params ) ? ; } start_network . start_network ( ) ; Ok ( ( task_manager , client ) ) }
Start a node with the given parachain `Configuration` and relay chain `Configuration`.
Start a node with the given parachain ` Configuration ` and relay chain ` Configuration ` .
parachain_config
Configuration
collator_key
Arc<CollatorPair>
polkadot_config
polkadot_collator::Configuration
id
polkadot_primitives::v0::Id
validator
bool
parachain_config
Configuration
collator_key
Arc<CollatorPair>
polkadot_config
polkadot_collator::Configuration
id
polkadot_primitives::v0::Id
validator
bool