Skip to content

Commit

Permalink
Add option to enable telemetry.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Jul 25, 2020
1 parent 7104c42 commit 3206576
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use sc_service::{
config::{
NetworkConfiguration,
TaskType,
TelemetryEndpoints,
},
ChainSpec,
Configuration,
Expand Down Expand Up @@ -217,6 +218,8 @@ pub struct SubxtClientConfig<C: ChainSpec + 'static> {
pub chain_spec: C,
/// Role of the node.
pub role: Role,
/// Enable telemetry.
pub enable_telemetry: bool,
}

impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
Expand All @@ -235,6 +238,14 @@ impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
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(),
Expand All @@ -253,8 +264,8 @@ impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
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(),
Expand Down Expand Up @@ -345,6 +356,7 @@ mod tests {
keystore: KeystoreConfig::InMemory,
chain_spec,
role: Role::Light,
enable_telemetry: false,
};
let client = ClientBuilder::<NodeTemplateRuntime>::new()
.set_client(
Expand Down Expand Up @@ -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::<NodeTemplateRuntime>::new()
.set_client(
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3206576

Please sign in to comment.