pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
	let (client, backend, keystore_container, mut task_manager, on_demand) =
		sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;

	let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
		config.transaction_pool.clone(),
		config.prometheus_registry(),
		task_manager.spawn_handle(),
		client.clone(),
		on_demand.clone(),
	));

	let select_chain = sc_consensus::LongestChain::new(backend.clone());

	let (grandpa_block_import, _) =
		sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?;
	let finality_proof_import = grandpa_block_import.clone();

	let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
		sc_consensus_babe::Config::get_or_compute(&*client)?,
		grandpa_block_import,
		client.clone(),
	)?;

	let import_queue = sc_consensus_babe::import_queue(
		babe_link,
		babe_block_import,
		Some(Box::new(finality_proof_import)),
		client.clone(),
		select_chain,
		InherentDataProviders::new(),
		&task_manager.spawn_essential_handle(),
		config.prometheus_registry(),
		sp_consensus::NeverCanAuthor,
	)?;

	let (network, network_status_sinks, system_rpc_tx, network_starter) =
		sc_service::build_network(sc_service::BuildNetworkParams {
			config: &config,
			client: client.clone(),
			transaction_pool: transaction_pool.clone(),
			spawn_handle: task_manager.spawn_handle(),
			import_queue,
			on_demand: Some(on_demand.clone()),
			block_announce_validator_builder: None,
		})?;

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

	let telemetry_span = TelemetrySpan::new();
	let _telemetry_span_entered = telemetry_span.enter();

	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
		remote_blockchain: Some(backend.remote_blockchain()),
		transaction_pool,
		task_manager: &mut task_manager,
		on_demand: Some(on_demand),
		rpc_extensions_builder: Box::new(|_, _| ()),
		config,
		client,
		keystore: keystore_container.sync_keystore(),
		backend,
		network,
		network_status_sinks,
		system_rpc_tx,
		telemetry_span: Some(telemetry_span.clone()),
	})?;

	network_starter.start_network();

	Ok(task_manager)
}
/// Builds a new service for a light client.
Builds a new service for a light client.
Builds a new service for a light client .
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
	let (client, backend, keystore_container, mut task_manager, on_demand) =
		sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
	let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
		config.transaction_pool.clone(),
		config.prometheus_registry(),
		task_manager.spawn_handle(),
		client.clone(),
		on_demand.clone(),
	));
	let select_chain = sc_consensus::LongestChain::new(backend.clone());
	let (grandpa_block_import, _) =
		sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?;
	let finality_proof_import = grandpa_block_import.clone();
	let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
		sc_consensus_babe::Config::get_or_compute(&*client)?,
		grandpa_block_import,
		client.clone(),
	)?;
	let import_queue = sc_consensus_babe::import_queue(
		babe_link,
		babe_block_import,
		Some(Box::new(finality_proof_import)),
		client.clone(),
		select_chain,
		InherentDataProviders::new(),
		&task_manager.spawn_essential_handle(),
		config.prometheus_registry(),
		sp_consensus::NeverCanAuthor,
	)?;
	let (network, network_status_sinks, system_rpc_tx, network_starter) =
		sc_service::build_network(sc_service::BuildNetworkParams {
			config: &config,
			client: client.clone(),
			transaction_pool: transaction_pool.clone(),
			spawn_handle: task_manager.spawn_handle(),
			import_queue,
			on_demand: Some(on_demand.clone()),
			block_announce_validator_builder: None,
		})?;
	if config.offchain_worker.enabled {
		sc_service::build_offchain_workers(
			&config,
			backend.clone(),
			task_manager.spawn_handle(),
			client.clone(),
			network.clone(),
		);
	}
	let telemetry_span = TelemetrySpan::new();
	let _telemetry_span_entered = telemetry_span.enter();
	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
		remote_blockchain: Some(backend.remote_blockchain()),
		transaction_pool,
		task_manager: &mut task_manager,
		on_demand: Some(on_demand),
		rpc_extensions_builder: Box::new(|_, _| ()),
		config,
		client,
		keystore: keystore_container.sync_keystore(),
		backend,
		network,
		network_status_sinks,
		system_rpc_tx,
		telemetry_span: Some(telemetry_span.clone()),
	})?;
	network_starter.start_network();
	Ok(task_manager)
}
pub fn new_light ( config : Configuration ) -> Result < TaskManager , ServiceError > { let ( client , backend , keystore_container , mut task_manager , on_demand ) = sc_service :: new_light_parts :: < Block , RuntimeApi , Executor > ( & config ) ? ; let transaction_pool = Arc :: new ( sc_transaction_pool :: BasicPool :: new_light ( config . transaction_pool . clone ( ) , config . prometheus_registry ( ) , task_manager . spawn_handle ( ) , client . clone ( ) , on_demand . clone ( ) , ) ) ; let select_chain = sc_consensus :: LongestChain :: new ( backend . clone ( ) ) ; let ( grandpa_block_import , _ ) = sc_finality_grandpa :: block_import ( client . clone ( ) , & ( client . clone ( ) as Arc < _ > ) , select_chain . clone ( ) ) ? ; let finality_proof_import = grandpa_block_import . clone ( ) ; let ( babe_block_import , babe_link ) = sc_consensus_babe :: block_import ( sc_consensus_babe :: Config :: get_or_compute ( & * client ) ? , grandpa_block_import , client . clone ( ) , ) ? ; let import_queue = sc_consensus_babe :: import_queue ( babe_link , babe_block_import , Some ( Box :: new ( finality_proof_import ) ) , client . clone ( ) , select_chain , InherentDataProviders :: new ( ) , & task_manager . spawn_essential_handle ( ) , config . prometheus_registry ( ) , sp_consensus :: NeverCanAuthor , ) ? ; let ( network , network_status_sinks , system_rpc_tx , network_starter ) = sc_service :: build_network ( sc_service :: BuildNetworkParams { config : & config , client : client . clone ( ) , transaction_pool : transaction_pool . clone ( ) , spawn_handle : task_manager . spawn_handle ( ) , import_queue , on_demand : Some ( on_demand . clone ( ) ) , block_announce_validator_builder : None , } ) ? ; if config . offchain_worker . enabled { sc_service :: build_offchain_workers ( & config , backend . clone ( ) , task_manager . spawn_handle ( ) , client . clone ( ) , network . clone ( ) , ) ; } let telemetry_span = TelemetrySpan :: new ( ) ; let _telemetry_span_entered = telemetry_span . enter ( ) ; sc_service :: spawn_tasks ( sc_service :: SpawnTasksParams { remote_blockchain : Some ( backend . remote_blockchain ( ) ) , transaction_pool , task_manager : & mut task_manager , on_demand : Some ( on_demand ) , rpc_extensions_builder : Box :: new ( | _ , _ | ( ) ) , config , client , keystore : keystore_container . sync_keystore ( ) , backend , network , network_status_sinks , system_rpc_tx , telemetry_span : Some ( telemetry_span . clone ( ) ) , } ) ? ; network_starter . start_network ( ) ; Ok ( task_manager ) }
Builds a new service for a light client.
Builds a new service for a light client .
config
Configuration