| 485 | } |
| 486 | |
| 487 | UniValue getnetworkinfo(const UniValue& params, bool fHelp) |
| 488 | { |
| 489 | if (fHelp || params.size() != 0) |
| 490 | throw runtime_error( |
| 491 | "getnetworkinfo\n" |
| 492 | "Returns an object containing various state info regarding P2P networking.\n" |
| 493 | "\nResult:\n" |
| 494 | "{\n" |
| 495 | " \"version\": xxxxx, (numeric) the server version\n" |
| 496 | " \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n" |
| 497 | " \"protocolversion\": xxxxx, (numeric) the protocol version\n" |
| 498 | " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" |
| 499 | " \"timeoffset\": xxxxx, (numeric) the time offset\n" |
| 500 | " \"connections\": xxxxx, (numeric) the number of connections\n" |
| 501 | " \"networks\": [ (array) information per network\n" |
| 502 | " {\n" |
| 503 | " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n" |
| 504 | " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n" |
| 505 | " \"reachable\": true|false, (boolean) is the network reachable?\n" |
| 506 | " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n" |
| 507 | " }\n" |
| 508 | " ,...\n" |
| 509 | " ],\n" |
| 510 | " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in bcc/kb\n" |
| 511 | " \"localaddresses\": [ (array) list of local addresses\n" |
| 512 | " {\n" |
| 513 | " \"address\": \"xxxx\", (string) network address\n" |
| 514 | " \"port\": xxx, (numeric) network port\n" |
| 515 | " \"score\": xxx (numeric) relative score\n" |
| 516 | " }\n" |
| 517 | " ,...\n" |
| 518 | " ]\n" |
| 519 | "}\n" |
| 520 | "\nExamples:\n" |
| 521 | + HelpExampleCli("getnetworkinfo", "") |
| 522 | + HelpExampleRpc("getnetworkinfo", "") |
| 523 | ); |
| 524 | |
| 525 | LOCK(cs_main); |
| 526 | |
| 527 | UniValue obj(UniValue::VOBJ); |
| 528 | obj.push_back(Pair("version", CLIENT_VERSION)); |
| 529 | obj.push_back(Pair("subversion", |
| 530 | FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()))); |
| 531 | obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); |
| 532 | obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices))); |
| 533 | obj.push_back(Pair("timeoffset", GetTimeOffset())); |
| 534 | obj.push_back(Pair("connections", (int)vNodes.size())); |
| 535 | obj.push_back(Pair("networks", GetNetworksInfo())); |
| 536 | obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); |
| 537 | UniValue localAddresses(UniValue::VARR); |
| 538 | { |
| 539 | LOCK(cs_mapLocalHost); |
| 540 | BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) |
| 541 | { |
| 542 | UniValue rec(UniValue::VOBJ); |
| 543 | rec.push_back(Pair("address", item.first.ToString())); |
| 544 | rec.push_back(Pair("port", item.second.nPort)); |
nothing calls this directly
no test coverage detected