Skip to content

Commit 1280ec8

Browse files
committed
Add option to enable telemetry.
1 parent 7104c42 commit 1280ec8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

client/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use sc_service::{
5353
config::{
5454
NetworkConfiguration,
5555
TaskType,
56+
TelemetryEndpoints,
5657
},
5758
ChainSpec,
5859
Configuration,
@@ -217,6 +218,8 @@ pub struct SubxtClientConfig<C: ChainSpec + 'static> {
217218
pub chain_spec: C,
218219
/// Role of the node.
219220
pub role: Role,
221+
/// Enable telemetry.
222+
pub enable_telemetry: bool,
220223
}
221224

222225
impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
@@ -235,6 +238,14 @@ impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
235238
wasm_external_transport: None,
236239
use_yamux_flow_control: true,
237240
};
241+
let telemetry_endpoints = if self.enable_telemetry {
242+
let endpoints =
243+
TelemetryEndpoints::new(vec![("/ip4/127.0.0.1/tcp/99000/ws".into(), 0)])
244+
.expect("valid config; qed");
245+
Some(endpoints)
246+
} else {
247+
None
248+
};
238249
let service_config = Configuration {
239250
network,
240251
impl_name: self.impl_name.to_string(),
@@ -253,8 +264,8 @@ impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
253264
max_runtime_instances: 8,
254265
announce_block: true,
255266
dev_key_seed: self.role.into(),
267+
telemetry_endpoints,
256268

257-
telemetry_endpoints: Default::default(),
258269
telemetry_external_transport: Default::default(),
259270
default_heap_pages: Default::default(),
260271
disable_grandpa: Default::default(),

0 commit comments

Comments
 (0)