diff --git a/src/client/nano-client.ts b/src/client/nano-client.ts index a0b2873..ce31713 100644 --- a/src/client/nano-client.ts +++ b/src/client/nano-client.ts @@ -486,6 +486,21 @@ export class NanoClient { }); } + /** + * Return metrics from other nodes on the network. By default, + * returns a summarized view of the whole network.\ + * Networking - node telemetry contains more detailed information on the protocol implementation of telemetry. + * * @param {body} TelemetryBody - https://docs.nano.org/commands/rpc-protocol/#telemetry + */ + telemetry(body?: { raw: false }): Promise; + telemetry(body: { raw: true }): Promise; + telemetry(body: { address: string; port: number; raw?: boolean }): Promise; + telemetry( + body? + ): Promise { + return this._send('telemetry', body ?? {}) as any; + } + /** * Check whether account is a valid account number using checksum. * @param {string} account - The NANO account address. diff --git a/src/types/rpc-response.ts b/src/types/rpc-response.ts index 910e73b..ac2257a 100644 --- a/src/types/rpc-response.ts +++ b/src/types/rpc-response.ts @@ -242,3 +242,36 @@ export type WorkGenerateResponse = { multiplier: string; hash: string; }; + +export type TelemetryResponse = { + block_count: string; + cemented_count: string; + unchecked_count: string; + account_count: string; + bandwidth_cap: string; + peer_count: string; + protocol_version: string; + uptime: string; + genesis_block: string; + major_version: string; + minor_version: string; + patch_version: string; + pre_release_version: string; + maker: string; + timestamp: string; + active_difficulty: string; +}; + +export type TelemetryRawResponse = { + metrics: (TelemetryResponse & { + signature: string; + node_id: string; + address: string; + port: string; + })[]; +}; + +export type TelemetryAddressPortResponse = TelemetryResponse & { + node_id: string; + signature: string; +};