pub fn new_full(config: Configuration)
	-> Result<impl AbstractService, ServiceError>
{
	let is_authority = config.roles.is_authority();
	let force_authoring = config.force_authoring;
	let name = config.name.clone();
	let disable_grandpa = config.disable_grandpa;

	// sentry nodes announce themselves as authorities to the network
	// and should run the same protocols authorities do, but it should
	// never actively participate in any consensus process.
	let participates_in_consensus = is_authority && !config.sentry_mode;

	let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);

	let (block_import, grandpa_link) =
		import_setup.take()
			.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");

	let service = 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()?;

	if participates_in_consensus {
		let proposer = sc_basic_authorship::ProposerFactory::new(
			service.client(),
			service.transaction_pool()
		);

		let client = service.client();
		let select_chain = service.select_chain()
			.ok_or(ServiceError::SelectChainRequired)?;

		let can_author_with =
			sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());

		let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
			sc_consensus_aura::slot_duration(&*client)?,
			client,
			select_chain,
			block_import,
			proposer,
			service.network(),
			inherent_data_providers.clone(),
			force_authoring,
			service.keystore(),
			can_author_with,
		)?;

		// the AURA authoring task is considered essential, i.e. if it
		// fails we take down the service with it.
		service.spawn_essential_task("aura", aura);
	}

	// if the node isn't actively participating in consensus then it doesn't
	// need a keystore, regardless of which protocol we use below.
	let keystore = if participates_in_consensus {
		Some(service.keystore())
	} else {
		None
	};

	let grandpa_config = grandpa::Config {
		// FIXME #1578 make this available through chainspec
		gossip_duration: Duration::from_millis(333),
		justification_period: 512,
		name: Some(name),
		observer_enabled: false,
		keystore,
		is_authority,
	};

	let enable_grandpa = !disable_grandpa;
	if enable_grandpa {
		// start the full GRANDPA voter
		// NOTE: non-authorities could run the GRANDPA observer protocol, but at
		// this point the full voter should provide better guarantees of block
		// and vote data availability than the observer. The observer has not
		// been tested extensively yet and having most nodes in a network run it
		// could lead to finality stalls.
		let grandpa_config = grandpa::GrandpaParams {
			config: grandpa_config,
			link: grandpa_link,
			network: service.network(),
			inherent_data_providers: inherent_data_providers.clone(),
			telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
			voting_rule: grandpa::VotingRulesBuilder::default().build(),
			prometheus_registry: service.prometheus_registry()
		};

		// the GRANDPA voter task is considered infallible, i.e.
		// if it fails we take down the service with it.
		service.spawn_essential_task(
			"grandpa-voter",
			grandpa::run_grandpa_voter(grandpa_config)?
		);
	} else {
		grandpa::setup_disabled_grandpa(
			service.client(),
			&inherent_data_providers,
			service.network(),
		)?;
	}

	Ok(service)
}
/// Builds a new service for a full client.
Builds a new service for a full client.
Builds a new service for a full client .
pub fn new_full(config: Configuration)
	-> Result<impl AbstractService, ServiceError>
{
	let is_authority = config.roles.is_authority();
	let force_authoring = config.force_authoring;
	let name = config.name.clone();
	let disable_grandpa = config.disable_grandpa;
	// sentry nodes announce themselves as authorities to the network
	// and should run the same protocols authorities do, but it should
	// never actively participate in any consensus process.
	let participates_in_consensus = is_authority && !config.sentry_mode;
	let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
	let (block_import, grandpa_link) =
		import_setup.take()
			.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
	let service = 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()?;
	if participates_in_consensus {
		let proposer = sc_basic_authorship::ProposerFactory::new(
			service.client(),
			service.transaction_pool()
		);
		let client = service.client();
		let select_chain = service.select_chain()
			.ok_or(ServiceError::SelectChainRequired)?;
		let can_author_with =
			sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
		let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
			sc_consensus_aura::slot_duration(&*client)?,
			client,
			select_chain,
			block_import,
			proposer,
			service.network(),
			inherent_data_providers.clone(),
			force_authoring,
			service.keystore(),
			can_author_with,
		)?;
		// the AURA authoring task is considered essential, i.e. if it
		// fails we take down the service with it.
		service.spawn_essential_task("aura", aura);
	}
	// if the node isn't actively participating in consensus then it doesn't
	// need a keystore, regardless of which protocol we use below.
	let keystore = if participates_in_consensus {
		Some(service.keystore())
	} else {
		None
	};
	let grandpa_config = grandpa::Config {
		// FIXME #1578 make this available through chainspec
		gossip_duration: Duration::from_millis(333),
		justification_period: 512,
		name: Some(name),
		observer_enabled: false,
		keystore,
		is_authority,
	};
	let enable_grandpa = !disable_grandpa;
	if enable_grandpa {
		// start the full GRANDPA voter
		// NOTE: non-authorities could run the GRANDPA observer protocol, but at
		// this point the full voter should provide better guarantees of block
		// and vote data availability than the observer. The observer has not
		// been tested extensively yet and having most nodes in a network run it
		// could lead to finality stalls.
		let grandpa_config = grandpa::GrandpaParams {
			config: grandpa_config,
			link: grandpa_link,
			network: service.network(),
			inherent_data_providers: inherent_data_providers.clone(),
			telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
			voting_rule: grandpa::VotingRulesBuilder::default().build(),
			prometheus_registry: service.prometheus_registry()
		};
		// the GRANDPA voter task is considered infallible, i.e.
		// if it fails we take down the service with it.
		service.spawn_essential_task(
			"grandpa-voter",
			grandpa::run_grandpa_voter(grandpa_config)?
		);
	} else {
		grandpa::setup_disabled_grandpa(
			service.client(),
			&inherent_data_providers,
			service.network(),
		)?;
	}
	Ok(service)
}
pub fn new_full ( config : Configuration ) -> Result < impl AbstractService , ServiceError > { let is_authority = config . roles . is_authority ( ) ; let force_authoring = config . force_authoring ; let name = config . name . clone ( ) ; let disable_grandpa = config . disable_grandpa ; // sentry nodes announce themselves as authorities to the network // and should run the same protocols authorities do, but it should // never actively participate in any consensus process. let participates_in_consensus = is_authority && ! config . sentry_mode ; let ( builder , mut import_setup , inherent_data_providers ) = new_full_start ! ( config ) ; let ( block_import , grandpa_link ) = import_setup . take ( ) . expect ( " " ) ; let service = 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 ( ) ? ; if participates_in_consensus { let proposer = sc_basic_authorship :: ProposerFactory :: new ( service . client ( ) , service . transaction_pool ( ) ) ; let client = service . client ( ) ; let select_chain = service . select_chain ( ) . ok_or ( ServiceError :: SelectChainRequired ) ? ; let can_author_with = sp_consensus :: CanAuthorWithNativeVersion :: new ( client . executor ( ) . clone ( ) ) ; let aura = sc_consensus_aura :: start_aura :: < _ , _ , _ , _ , _ , AuraPair , _ , _ , _ > ( sc_consensus_aura :: slot_duration ( & * client ) ? , client , select_chain , block_import , proposer , service . network ( ) , inherent_data_providers . clone ( ) , force_authoring , service . keystore ( ) , can_author_with , ) ? ; // the AURA authoring task is considered essential, i.e. if it // fails we take down the service with it. service . spawn_essential_task ( " " , aura ) ; } // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. let keystore = if participates_in_consensus { Some ( service . keystore ( ) ) } else { None } ; let grandpa_config = grandpa :: Config { // FIXME #1578 make this available through chainspec gossip_duration : Duration :: from_millis ( 333 ) , justification_period : 512 , name : Some ( name ) , observer_enabled : false , keystore , is_authority , } ; let enable_grandpa = ! disable_grandpa ; if enable_grandpa { // start the full GRANDPA voter // NOTE: non-authorities could run the GRANDPA observer protocol, but at // this point the full voter should provide better guarantees of block // and vote data availability than the observer. The observer has not // been tested extensively yet and having most nodes in a network run it // could lead to finality stalls. let grandpa_config = grandpa :: GrandpaParams { config : grandpa_config , link : grandpa_link , network : service . network ( ) , inherent_data_providers : inherent_data_providers . clone ( ) , telemetry_on_connect : Some ( service . telemetry_on_connect_stream ( ) ) , voting_rule : grandpa :: VotingRulesBuilder :: default ( ) . build ( ) , prometheus_registry : service . prometheus_registry ( ) } ; // the GRANDPA voter task is considered infallible, i.e. // if it fails we take down the service with it. service . spawn_essential_task ( " " , grandpa :: run_grandpa_voter ( grandpa_config ) ? ) ; } else { grandpa :: setup_disabled_grandpa ( service . client ( ) , & inherent_data_providers , service . network ( ) , ) ? ; } Ok ( service ) }
Builds a new service for a full client.
Builds a new service for a full client .
config
Configuration
config
Configuration