Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/client/nano-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RPC.TelemetryResponse>;
telemetry(body: { raw: true }): Promise<RPC.TelemetryRawResponse>;
telemetry(body: { address: string; port: number; raw?: boolean }): Promise<RPC.TelemetryAddressPortResponse>;
telemetry(
body?
): Promise<RPC.TelemetryResponse | RPC.TelemetryRawResponse | RPC.TelemetryAddressPortResponse> {
return this._send('telemetry', body ?? {}) as any;
}

/**
* Check whether account is a valid account number using checksum.
* @param {string} account - The NANO account address.
Expand Down
33 changes: 33 additions & 0 deletions src/types/rpc-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};