| 66 | } |
| 67 | |
| 68 | static UniValue getpeerinfo(const JSONRPCRequest& request) |
| 69 | { |
| 70 | if (request.fHelp || request.params.size() != 0) |
| 71 | throw std::runtime_error( |
| 72 | "getpeerinfo\n" |
| 73 | "\nReturns data about each connected network node as a json array of objects.\n" |
| 74 | "\nResult:\n" |
| 75 | "[\n" |
| 76 | " {\n" |
| 77 | " \"id\": n, (numeric) Peer index\n" |
| 78 | " \"addr\":\"host:port\", (string) The IP address and port of the peer\n" |
| 79 | " \"addrbind\":\"ip:port\", (string) Bind address of the connection to the peer\n" |
| 80 | " \"addrlocal\":\"ip:port\", (string) Local address as reported by the peer\n" |
| 81 | " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n" |
| 82 | " \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n" |
| 83 | " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n" |
| 84 | " \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n" |
| 85 | " \"bytessent\": n, (numeric) The total bytes sent\n" |
| 86 | " \"bytesrecv\": n, (numeric) The total bytes received\n" |
| 87 | " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n" |
| 88 | " \"timeoffset\": ttt, (numeric) The time offset in seconds\n" |
| 89 | " \"pingtime\": n, (numeric) ping time (if available)\n" |
| 90 | " \"minping\": n, (numeric) minimum observed ping time (if any at all)\n" |
| 91 | " \"pingwait\": n, (numeric) ping wait (if non-zero)\n" |
| 92 | " \"version\": v, (numeric) The peer version, such as 70001\n" |
| 93 | " \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n" |
| 94 | " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" |
| 95 | " \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n" |
| 96 | " \"startingheight\": n, (numeric) The starting height (block) of the peer\n" |
| 97 | " \"banscore\": n, (numeric) The ban score\n" |
| 98 | " \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" |
| 99 | " \"synced_blocks\": n, (numeric) The last block we have in common with this peer\n" |
| 100 | " \"inflight\": [\n" |
| 101 | " n, (numeric) The heights of blocks we're currently asking from this peer\n" |
| 102 | " ...\n" |
| 103 | " ],\n" |
| 104 | " \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n" |
| 105 | " \"bytessent_per_msg\": {\n" |
| 106 | " \"addr\": n, (numeric) The total bytes sent aggregated by message type\n" |
| 107 | " ...\n" |
| 108 | " },\n" |
| 109 | " \"bytesrecv_per_msg\": {\n" |
| 110 | " \"addr\": n, (numeric) The total bytes received aggregated by message type\n" |
| 111 | " ...\n" |
| 112 | " }\n" |
| 113 | " }\n" |
| 114 | " ,...\n" |
| 115 | "]\n" |
| 116 | "\nExamples:\n" |
| 117 | + HelpExampleCli("getpeerinfo", "") |
| 118 | + HelpExampleRpc("getpeerinfo", "") |
| 119 | ); |
| 120 | |
| 121 | if(!g_connman) |
| 122 | throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); |
| 123 | |
| 124 | std::vector<CNodeStats> vstats; |
| 125 | g_connman->GetNodeStats(vstats); |
nothing calls this directly
no test coverage detected