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
+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()