Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/net.cpp
Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | static UniValue getaddednodeinfo(const Config &config, | ||||
for (const AddedNodeInfo &info : vInfo) { | for (const AddedNodeInfo &info : vInfo) { | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("addednode", info.strAddedNode); | obj.pushKV("addednode", info.strAddedNode); | ||||
obj.pushKV("connected", info.fConnected); | obj.pushKV("connected", info.fConnected); | ||||
UniValue addresses(UniValue::VARR); | UniValue addresses(UniValue::VARR); | ||||
if (info.fConnected) { | if (info.fConnected) { | ||||
UniValue address(UniValue::VOBJ); | UniValue address(UniValue::VOBJ); | ||||
address.pushKV("address", info.resolvedAddress.ToString()); | address.pushKV("address", info.resolvedAddress.ToString()); | ||||
address.push_back( | address.pushKV("connected", info.fInbound ? "inbound" : "outbound"); | ||||
Pair("connected", info.fInbound ? "inbound" : "outbound")); | |||||
addresses.push_back(address); | addresses.push_back(address); | ||||
} | } | ||||
obj.pushKV("addresses", addresses); | obj.pushKV("addresses", addresses); | ||||
ret.push_back(obj); | ret.push_back(obj); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
Show All 40 Lines | static UniValue getnettotals(const Config &config, | ||||
} | } | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("totalbytesrecv", g_connman->GetTotalBytesRecv()); | obj.pushKV("totalbytesrecv", g_connman->GetTotalBytesRecv()); | ||||
obj.pushKV("totalbytessent", g_connman->GetTotalBytesSent()); | obj.pushKV("totalbytessent", g_connman->GetTotalBytesSent()); | ||||
obj.pushKV("timemillis", GetTimeMillis()); | obj.pushKV("timemillis", GetTimeMillis()); | ||||
UniValue outboundLimit(UniValue::VOBJ); | UniValue outboundLimit(UniValue::VOBJ); | ||||
outboundLimit.push_back( | outboundLimit.pushKV("timeframe", g_connman->GetMaxOutboundTimeframe()); | ||||
Pair("timeframe", g_connman->GetMaxOutboundTimeframe())); | |||||
outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget()); | outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget()); | ||||
outboundLimit.push_back( | outboundLimit.pushKV("target_reached", | ||||
Pair("target_reached", g_connman->OutboundTargetReached(false))); | g_connman->OutboundTargetReached(false)); | ||||
outboundLimit.push_back(Pair("serve_historical_blocks", | outboundLimit.pushKV("serve_historical_blocks", | ||||
!g_connman->OutboundTargetReached(true))); | !g_connman->OutboundTargetReached(true)); | ||||
outboundLimit.push_back( | outboundLimit.pushKV("bytes_left_in_cycle", | ||||
Pair("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft())); | g_connman->GetOutboundTargetBytesLeft()); | ||||
outboundLimit.push_back( | outboundLimit.pushKV("time_left_in_cycle", | ||||
Pair("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle())); | g_connman->GetMaxOutboundTimeLeftInCycle()); | ||||
obj.pushKV("uploadtarget", outboundLimit); | obj.pushKV("uploadtarget", outboundLimit); | ||||
return obj; | return obj; | ||||
} | } | ||||
static UniValue GetNetworksInfo() { | static UniValue GetNetworksInfo() { | ||||
UniValue networks(UniValue::VARR); | UniValue networks(UniValue::VARR); | ||||
for (int n = 0; n < NET_MAX; ++n) { | for (int n = 0; n < NET_MAX; ++n) { | ||||
enum Network network = static_cast<enum Network>(n); | enum Network network = static_cast<enum Network>(n); | ||||
if (network == NET_UNROUTABLE || network == NET_INTERNAL) { | if (network == NET_UNROUTABLE || network == NET_INTERNAL) { | ||||
continue; | continue; | ||||
} | } | ||||
proxyType proxy; | proxyType proxy; | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
GetProxy(network, proxy); | GetProxy(network, proxy); | ||||
obj.pushKV("name", GetNetworkName(network)); | obj.pushKV("name", GetNetworkName(network)); | ||||
obj.pushKV("limited", IsLimited(network)); | obj.pushKV("limited", IsLimited(network)); | ||||
obj.pushKV("reachable", IsReachable(network)); | obj.pushKV("reachable", IsReachable(network)); | ||||
obj.push_back(Pair("proxy", | obj.pushKV("proxy", | ||||
proxy.IsValid() ? proxy.proxy.ToStringIPPort() | proxy.IsValid() ? proxy.proxy.ToStringIPPort() | ||||
: std::string())); | : std::string()); | ||||
obj.push_back( | obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials); | ||||
Pair("proxy_randomize_credentials", proxy.randomize_credentials)); | |||||
networks.push_back(obj); | networks.push_back(obj); | ||||
} | } | ||||
return networks; | return networks; | ||||
} | } | ||||
static UniValue getnetworkinfo(const Config &config, | static UniValue getnetworkinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | static UniValue getnetworkinfo(const Config &config, | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("version", CLIENT_VERSION); | obj.pushKV("version", CLIENT_VERSION); | ||||
obj.pushKV("subversion", userAgent(config)); | obj.pushKV("subversion", userAgent(config)); | ||||
obj.pushKV("protocolversion", PROTOCOL_VERSION); | obj.pushKV("protocolversion", PROTOCOL_VERSION); | ||||
if (g_connman) { | if (g_connman) { | ||||
obj.push_back(Pair("localservices", | obj.pushKV("localservices", | ||||
strprintf("%016x", g_connman->GetLocalServices()))); | strprintf("%016x", g_connman->GetLocalServices())); | ||||
} | } | ||||
obj.pushKV("localrelay", fRelayTxes); | obj.pushKV("localrelay", fRelayTxes); | ||||
obj.pushKV("timeoffset", GetTimeOffset()); | obj.pushKV("timeoffset", GetTimeOffset()); | ||||
if (g_connman) { | if (g_connman) { | ||||
obj.pushKV("networkactive", g_connman->GetNetworkActive()); | obj.pushKV("networkactive", g_connman->GetNetworkActive()); | ||||
obj.push_back(Pair("connections", int(g_connman->GetNodeCount( | obj.pushKV("connections", | ||||
CConnman::CONNECTIONS_ALL)))); | int(g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); | ||||
} | } | ||||
obj.pushKV("networks", GetNetworksInfo()); | obj.pushKV("networks", GetNetworksInfo()); | ||||
obj.push_back(Pair("relayfee", | obj.pushKV("relayfee", | ||||
ValueFromAmount(config.GetMinFeePerKB().GetFeePerK()))); | ValueFromAmount(config.GetMinFeePerKB().GetFeePerK())); | ||||
obj.push_back(Pair("excessutxocharge", | obj.pushKV("excessutxocharge", | ||||
ValueFromAmount(config.GetExcessUTXOCharge()))); | ValueFromAmount(config.GetExcessUTXOCharge())); | ||||
UniValue localAddresses(UniValue::VARR); | UniValue localAddresses(UniValue::VARR); | ||||
{ | { | ||||
LOCK(cs_mapLocalHost); | LOCK(cs_mapLocalHost); | ||||
for (const std::pair<CNetAddr, LocalServiceInfo> &item : mapLocalHost) { | for (const std::pair<CNetAddr, LocalServiceInfo> &item : mapLocalHost) { | ||||
UniValue rec(UniValue::VOBJ); | UniValue rec(UniValue::VOBJ); | ||||
rec.pushKV("address", item.first.ToString()); | rec.pushKV("address", item.first.ToString()); | ||||
rec.pushKV("port", item.second.nPort); | rec.pushKV("port", item.second.nPort); | ||||
rec.pushKV("score", item.second.nScore); | rec.pushKV("score", item.second.nScore); | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |