|
|
@ -36,9 +36,10 @@ UniValue getconnectioncount(const UniValue& params, bool fHelp) |
|
|
|
+ HelpExampleRpc("getconnectioncount", "") |
|
|
|
+ HelpExampleRpc("getconnectioncount", "") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
LOCK2(cs_main, cs_vNodes); |
|
|
|
if(!g_connman) |
|
|
|
|
|
|
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); |
|
|
|
|
|
|
|
|
|
|
|
return (int)vNodes.size(); |
|
|
|
return (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UniValue ping(const UniValue& params, bool fHelp) |
|
|
|
UniValue ping(const UniValue& params, bool fHelp) |
|
|
@ -64,19 +65,6 @@ UniValue ping(const UniValue& params, bool fHelp) |
|
|
|
return NullUniValue; |
|
|
|
return NullUniValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void CopyNodeStats(std::vector<CNodeStats>& vstats) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vstats.clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOCK(cs_vNodes); |
|
|
|
|
|
|
|
vstats.reserve(vNodes.size()); |
|
|
|
|
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) { |
|
|
|
|
|
|
|
CNodeStats stats; |
|
|
|
|
|
|
|
pnode->copyStats(stats); |
|
|
|
|
|
|
|
vstats.push_back(stats); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UniValue getpeerinfo(const UniValue& params, bool fHelp) |
|
|
|
UniValue getpeerinfo(const UniValue& params, bool fHelp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fHelp || params.size() != 0) |
|
|
|
if (fHelp || params.size() != 0) |
|
|
@ -127,10 +115,11 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) |
|
|
|
+ HelpExampleRpc("getpeerinfo", "") |
|
|
|
+ HelpExampleRpc("getpeerinfo", "") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
LOCK(cs_main); |
|
|
|
if(!g_connman) |
|
|
|
|
|
|
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); |
|
|
|
|
|
|
|
|
|
|
|
vector<CNodeStats> vstats; |
|
|
|
vector<CNodeStats> vstats; |
|
|
|
CopyNodeStats(vstats); |
|
|
|
g_connman->GetNodeStats(vstats); |
|
|
|
|
|
|
|
|
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
|
|
|
|
|
|
|
@ -253,11 +242,12 @@ UniValue disconnectnode(const UniValue& params, bool fHelp) |
|
|
|
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") |
|
|
|
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CNode* pNode = FindNode(params[0].get_str()); |
|
|
|
if(!g_connman) |
|
|
|
if (pNode == NULL) |
|
|
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); |
|
|
|
throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pNode->fDisconnect = true; |
|
|
|
bool ret = g_connman->DisconnectNode(params[0].get_str()); |
|
|
|
|
|
|
|
if (!ret) |
|
|
|
|
|
|
|
throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes"); |
|
|
|
|
|
|
|
|
|
|
|
return NullUniValue; |
|
|
|
return NullUniValue; |
|
|
|
} |
|
|
|
} |
|
|
@ -435,7 +425,6 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
|
|
|
|
|
|
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
obj.push_back(Pair("version", CLIENT_VERSION)); |
|
|
|
obj.push_back(Pair("version", CLIENT_VERSION)); |
|
|
|
obj.push_back(Pair("subversion", strSubVersion)); |
|
|
|
obj.push_back(Pair("subversion", strSubVersion)); |
|
|
@ -443,7 +432,8 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) |
|
|
|
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices))); |
|
|
|
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices))); |
|
|
|
obj.push_back(Pair("localrelay", fRelayTxes)); |
|
|
|
obj.push_back(Pair("localrelay", fRelayTxes)); |
|
|
|
obj.push_back(Pair("timeoffset", GetTimeOffset())); |
|
|
|
obj.push_back(Pair("timeoffset", GetTimeOffset())); |
|
|
|
obj.push_back(Pair("connections", (int)vNodes.size())); |
|
|
|
if(g_connman) |
|
|
|
|
|
|
|
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); |
|
|
|
obj.push_back(Pair("networks", GetNetworksInfo())); |
|
|
|
obj.push_back(Pair("networks", GetNetworksInfo())); |
|
|
|
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); |
|
|
|
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); |
|
|
|
UniValue localAddresses(UniValue::VARR); |
|
|
|
UniValue localAddresses(UniValue::VARR); |
|
|
|