File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -486,6 +486,28 @@ export class NanoClient {
486486 } ) ;
487487 }
488488
489+ /**
490+ * Return metrics from other nodes on the network. By default,
491+ * returns a summarized view of the whole network.\
492+ * Networking - node telemetry contains more detailed information on the protocol implementation of telemetry.
493+ * * @param {body } TelemetryBody - https://docs.nano.org/commands/rpc-protocol/#telemetry
494+ */
495+ telemetry <
496+ T extends
497+ | { raw : boolean ; address ?: never ; port ?: never }
498+ | { address : string ; port : number ; raw ?: never }
499+ | never
500+ > (
501+ body ?: T
502+ ) : T extends { address : string ; port : number }
503+ ? Promise < RPC . TelemetryAddressPortResponse >
504+ : T extends { raw : true }
505+ ? Promise < RPC . TelemetryRawResponse >
506+ : Promise < RPC . TelemetryResponse > {
507+ console . log ( body ) ;
508+ return this . _send ( 'telemetry' , body ) as any ;
509+ }
510+
489511 /**
490512 * Check whether account is a valid account number using checksum.
491513 * @param {string } account - The NANO account address.
Original file line number Diff line number Diff line change @@ -242,3 +242,36 @@ export type WorkGenerateResponse = {
242242 multiplier : string ;
243243 hash : string ;
244244} ;
245+
246+ export type TelemetryResponse = {
247+ block_count : string ;
248+ cemented_count : string ;
249+ unchecked_count : string ;
250+ account_count : string ;
251+ bandwidth_cap : string ;
252+ peer_count : string ;
253+ protocol_version : string ;
254+ uptime : string ;
255+ genesis_block : string ;
256+ major_version : string ;
257+ minor_version : string ;
258+ patch_version : string ;
259+ pre_release_version : string ;
260+ maker : string ;
261+ timestamp : string ;
262+ active_difficulty : string ;
263+ } ;
264+
265+ export type TelemetryRawResponse = {
266+ metrics : ( TelemetryResponse & {
267+ signature : string ;
268+ node_id : string ;
269+ address : string ;
270+ port : string ;
271+ } ) [ ] ;
272+ } ;
273+
274+ export type TelemetryAddressPortResponse = TelemetryResponse & {
275+ node_id : string ;
276+ signature : string ;
277+ } ;
You can’t perform that action at this time.
0 commit comments