/
getnodeinfo.ts
33 lines (28 loc) 路 1.12 KB
/
getnodeinfo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Arguments } from 'yargs';
import { callback, loadXudClient } from '../command';
import Table, { VerticalTable } from 'cli-table3';
import colors from 'colors/safe';
import { GetNodeInfoRequest, GetNodeInfoResponse } from '../../proto/xudrpc_pb';
const displayNodeInfo = (node: GetNodeInfoResponse.AsObject) => {
const table = new Table() as VerticalTable;
const bannedTitle = colors.blue('Banned');
const reputationScore = colors.blue('Reputation Score');
table.push(
{ [bannedTitle]: node.banned }
, { [reputationScore]: node.reputationscore });
console.log(colors.underline(colors.bold('\nNode info:')));
console.log(table.toString());
};
export const command = 'getnodeinfo <node_key>';
export const describe = 'get general information about a peer';
export const builder = {
node_key: {
type: 'string',
description: 'the node key of the connected peer to get general information from',
},
};
export const handler = (argv: Arguments) => {
const request = new GetNodeInfoRequest();
request.setNodePubKey(argv.node_key);
loadXudClient(argv).getNodeInfo(request, callback(argv, displayNodeInfo));
};