Service various cleanups (#3238)

* Remove generic from sign()

* Remove mandatory RuntimeGenesis trait req

* Remove requirement from Configuration

* Relax trait bounds of core/cli

* Move method

* The config field is no longer public

* Remove Components from bounds of functions

* Implement DerefMut for LightComponents

* Implement Executor for Full/LightComponents

* Fix bad merge

* Fix forgotten config()

* Fix build
This commit is contained in:
Pierre Krieger
2019-08-08 16:14:30 +02:00
committed by Gavin Wood
parent fe18b4055d
commit bafc7202ca
8 changed files with 133 additions and 88 deletions
+2 -4
View File
@@ -26,10 +26,8 @@ use keyring::sr25519::Keyring;
use node_runtime::{Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall, ExistentialDeposit};
use primitives::{sr25519, crypto::Pair};
use sr_primitives::{generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension}};
use substrate_service::ServiceFactory;
use transaction_factory::RuntimeAdapter;
use transaction_factory::modes::Mode;
use crate::service;
use inherents::InherentData;
use timestamp;
use finality_tracker;
@@ -140,7 +138,7 @@ impl RuntimeAdapter for FactoryState<Number> {
let index = self.extract_index(&sender, prior_block_hash);
let phase = self.extract_phase(*prior_block_hash);
sign::<service::Factory, Self>(CheckedExtrinsic {
sign::<Self>(CheckedExtrinsic {
signed: Some((sender.clone(), Self::build_extra(index, phase))),
function: Call::Balances(
BalancesCall::transfer(
@@ -233,7 +231,7 @@ fn gen_seed_bytes(seed: u64) -> [u8; 32] {
/// Creates an `UncheckedExtrinsic` containing the appropriate signature for
/// a `CheckedExtrinsics`.
fn sign<F: ServiceFactory, RA: RuntimeAdapter>(
fn sign<RA: RuntimeAdapter>(
xt: CheckedExtrinsic,
key: &sr25519::Pair,
additional_signed: <SignedExtra as SignedExtension>::AdditionalSigned,
+1 -1
View File
@@ -186,7 +186,7 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
match &ret {
Ok(Some(CustomSubcommands::Factory(cli_args))) => {
let mut config = cli::create_config_with_db_path::<service::Factory, _>(
let mut config = cli::create_config_with_db_path(
load_spec,
&cli_args.shared_params,
&version,
+9 -9
View File
@@ -99,11 +99,11 @@ construct_service_factory! {
FullComponents::<Factory>::new(config) },
AuthoritySetup = {
|mut service: Self::FullService| {
let (block_import, link_half, babe_link) = service.config.custom.import_setup.take()
let (block_import, link_half, babe_link) = service.config_mut().custom.import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
// spawn any futures that were created in the previous setup steps
if let Some(tasks) = service.config.custom.tasks_to_spawn.take() {
if let Some(tasks) = service.config_mut().custom.tasks_to_spawn.take() {
for task in tasks {
service.spawn_task(
task.select(service.on_exit())
@@ -129,8 +129,8 @@ construct_service_factory! {
block_import,
env: proposer,
sync_oracle: service.network(),
inherent_data_providers: service.config.custom.inherent_data_providers.clone(),
force_authoring: service.config.force_authoring,
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
force_authoring: service.config().force_authoring,
time_source: babe_link,
};
@@ -142,12 +142,12 @@ construct_service_factory! {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 4096,
name: Some(service.config.name.clone()),
name: Some(service.config().name.clone()),
keystore: Some(service.keystore()),
};
if !service.config.disable_grandpa {
if service.config.roles.is_authority() {
if !service.config().disable_grandpa {
if service.config().roles.is_authority() {
let telemetry_on_connect = TelemetryOnConnect {
telemetry_connection_sinks: service.telemetry_on_connect_stream(),
};
@@ -155,7 +155,7 @@ construct_service_factory! {
config: config,
link: link_half,
network: service.network(),
inherent_data_providers: service.config.custom.inherent_data_providers.clone(),
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(telemetry_on_connect),
};
@@ -331,7 +331,7 @@ mod tests {
let block_factory = |service: &SyncService<<Factory as ServiceFactory>::FullService>| {
let service = service.get();
let mut inherent_data = service
.config
.config()
.custom
.inherent_data_providers
.create_inherent_data()