From 3206576e31020a8bc7a8efb248039bb998003f09 Mon Sep 17 00:00:00 2001 From: David Craven Date: Sat, 25 Jul 2020 18:32:01 +0200 Subject: [PATCH] Add option to enable telemetry. --- client/src/lib.rs | 15 ++++++++++++++- src/lib.rs | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index d2115b71f1..a335b11c48 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -53,6 +53,7 @@ use sc_service::{ config::{ NetworkConfiguration, TaskType, + TelemetryEndpoints, }, ChainSpec, Configuration, @@ -217,6 +218,8 @@ pub struct SubxtClientConfig { pub chain_spec: C, /// Role of the node. pub role: Role, + /// Enable telemetry. + pub enable_telemetry: bool, } impl SubxtClientConfig { @@ -235,6 +238,14 @@ impl SubxtClientConfig { wasm_external_transport: None, use_yamux_flow_control: true, }; + let telemetry_endpoints = if self.enable_telemetry { + let endpoints = + TelemetryEndpoints::new(vec![("/ip4/127.0.0.1/tcp/99000/ws".into(), 0)]) + .expect("valid config; qed"); + Some(endpoints) + } else { + None + }; let service_config = Configuration { network, impl_name: self.impl_name.to_string(), @@ -253,8 +264,8 @@ impl SubxtClientConfig { max_runtime_instances: 8, announce_block: true, dev_key_seed: self.role.into(), + telemetry_endpoints, - telemetry_endpoints: Default::default(), telemetry_external_transport: Default::default(), default_heap_pages: Default::default(), disable_grandpa: Default::default(), @@ -345,6 +356,7 @@ mod tests { keystore: KeystoreConfig::InMemory, chain_spec, role: Role::Light, + enable_telemetry: false, }; let client = ClientBuilder::::new() .set_client( @@ -377,6 +389,7 @@ mod tests { keystore: KeystoreConfig::InMemory, chain_spec: test_node::chain_spec::development_config().unwrap(), role: Role::Authority(AccountKeyring::Alice), + enable_telemetry: false, }; let client = ClientBuilder::::new() .set_client( diff --git a/src/lib.rs b/src/lib.rs index a1a79a45e2..5d8148e353 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -492,6 +492,7 @@ mod tests { }, chain_spec: test_node::chain_spec::development_config().unwrap(), role: Role::Authority(key), + enable_telemetry: false, }; let client = ClientBuilder::new() .set_client(