/// 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<impl AbstractService, ServiceError>
{
	let inherent_data_providers = InherentDataProviders::new();
	ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
		.with_select_chain(|_config, backend| {
			Ok(LongestChain::new(backend.clone()))
		})?
		.with_transaction_pool(|config, client, fetcher| {
			let fetcher = fetcher
				.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
			let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
			let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
				config, Arc::new(pool_api), sc_transaction_pool::RevalidationType::Light,
			);
			Ok(pool)
		})?
		.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
			let fetch_checker = fetcher
				.map(|fetcher| fetcher.checker().clone())
				.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
			let grandpa_block_import = grandpa::light_block_import(
				client.clone(),
				backend,
				&(client.clone() as Arc<_>),
				Arc::new(fetch_checker),
			)?;
			let finality_proof_import = grandpa_block_import.clone();
			let finality_proof_request_builder =
				finality_proof_import.create_finality_proof_request_builder();
			let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair>(
				sc_consensus_aura::slot_duration(&*client)?,
				grandpa_block_import,
				None,
				Some(Box::new(finality_proof_import)),
				client,
				inherent_data_providers.clone(),
			)?;
			Ok((import_queue, finality_proof_request_builder))
		})?
		.with_finality_proof_provider(|client, backend| {
			// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
			let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
			Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
		})?
		.build()
}
pub fn new_light ( config : Configuration ) -> Result < impl AbstractService , ServiceError > { let inherent_data_providers = InherentDataProviders :: new ( ) ; ServiceBuilder :: new_light :: < Block , RuntimeApi , Executor > ( config ) ? . with_select_chain ( | _config , backend | { Ok ( LongestChain :: new ( backend . clone ( ) ) ) } ) ? . with_transaction_pool ( | config , client , fetcher | { let fetcher = fetcher . ok_or_else ( | | " " ) ? ; let pool_api = sc_transaction_pool :: LightChainApi :: new ( client . clone ( ) , fetcher . clone ( ) ) ; let pool = sc_transaction_pool :: BasicPool :: with_revalidation_type ( config , Arc :: new ( pool_api ) , sc_transaction_pool :: RevalidationType :: Light , ) ; Ok ( pool ) } ) ? . with_import_queue_and_fprb ( | _config , client , backend , fetcher , _select_chain , _tx_pool | { let fetch_checker = fetcher . map ( | fetcher | fetcher . checker ( ) . clone ( ) ) . ok_or_else ( | | " " ) ? ; let grandpa_block_import = grandpa :: light_block_import ( client . clone ( ) , backend , & ( client . clone ( ) as Arc < _ > ) , Arc :: new ( fetch_checker ) , ) ? ; let finality_proof_import = grandpa_block_import . clone ( ) ; let finality_proof_request_builder = finality_proof_import . create_finality_proof_request_builder ( ) ; let import_queue = sc_consensus_aura :: import_queue :: < _ , _ , _ , AuraPair > ( sc_consensus_aura :: slot_duration ( & * client ) ? , grandpa_block_import , None , Some ( Box :: new ( finality_proof_import ) ) , client , inherent_data_providers . clone ( ) , ) ? ; Ok ( ( import_queue , finality_proof_request_builder ) ) } ) ? . with_finality_proof_provider ( | client , backend | { // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider let provider = client as Arc < dyn StorageAndProofProvider < _ , _ > > ; Ok ( Arc :: new ( GrandpaFinalityProofProvider :: new ( backend , provider ) ) as _ ) } ) ? . build ( ) }
Builds a new service for a light client.
Builds a new service for a light client .
config
Configuration