MCPcopy Create free account
hub / github.com/LUX-Core/lux / getnetworkinfo

Function getnetworkinfo

src/rpcnet.cpp:359–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359UniValue getnetworkinfo(const UniValue& params, bool fHelp)
360{
361 if (fHelp || params.size() != 0)
362 throw runtime_error(
363 "getnetworkinfo\n"
364 "Returns an object containing various state info regarding P2P networking.\n"
365 "\nResult:\n"
366 "{\n"
367 " \"version\": xxxxx, (numeric) the server version\n"
368 " \"subversion\": \"/Luxcore:x.x.x.x/\", (string) the server subversion string\n"
369 " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
370 " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
371 " \"timeoffset\": xxxxx, (numeric) the time offset\n"
372 " \"connections\": xxxxx, (numeric) the number of connections\n"
373 " \"networks\": [ (array) information per network\n"
374 " {\n"
375 " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n"
376 " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n"
377 " \"reachable\": true|false, (boolean) is the network reachable?\n"
378 " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n"
379 " }\n"
380 " ,...\n"
381 " ],\n"
382 " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in lux/kb\n"
383 " \"localaddresses\": [ (array) list of local addresses\n"
384 " {\n"
385 " \"address\": \"xxxx\", (string) network address\n"
386 " \"port\": xxx, (numeric) network port\n"
387 " \"score\": xxx (numeric) relative score\n"
388 " }\n"
389 " ,...\n"
390 " ]\n"
391 "}\n"
392 "\nExamples:\n" +
393 HelpExampleCli("getnetworkinfo", "") + HelpExampleRpc("getnetworkinfo", ""));
394
395 LOCK(cs_main);
396
397 UniValue obj(UniValue::VOBJ);
398 obj.push_back(Pair("version", CLIENT_VERSION));
399 obj.push_back(Pair("subversion",
400 FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>())));
401 obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
402 obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
403 obj.push_back(Pair("timeoffset", GetTimeOffset()));
404 obj.push_back(Pair("connections", (int)vNodes.size()));
405 obj.push_back(Pair("networks", GetNetworksInfo()));
406 obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
407 UniValue localAddresses(UniValue::VARR);
408 {
409 LOCK(cs_mapLocalHost);
410 for (const PAIRTYPE(CNetAddr, LocalServiceInfo) & item : mapLocalHost) {
411 UniValue rec(UniValue::VOBJ);
412 rec.push_back(Pair("address", item.first.ToString()));
413 rec.push_back(Pair("port", item.second.nPort));
414 rec.push_back(Pair("score", item.second.nScore));
415 localAddresses.push_back(rec);
416 }

Callers

nothing calls this directly

Calls 11

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
PairFunction · 0.85
FormatSubVersionFunction · 0.85
GetTimeOffsetFunction · 0.85
GetNetworksInfoFunction · 0.85
ValueFromAmountFunction · 0.85
GetFeePerKMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected