 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
26 if (fHelp || params.
size() != 0)
27 throw std::runtime_error(
28 "getconnectioncount\n"
29 "\nReturns the number of connections to other nodes.\n"
31 "n (numeric) The connection count\n"
41 if (fHelp || params.
size() != 0)
42 throw std::runtime_error(
44 "\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
45 "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
46 "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n"
53 pNode->fPingQueued =
true;
59 static void CopyNodeStats(std::vector<CNodeStats>& vstats)
64 vstats.reserve(
vNodes.size());
67 pnode->copyStats(stats);
68 vstats.push_back(stats);
74 if (fHelp || params.
size() != 0)
75 throw std::runtime_error(
77 "\nReturns data about each connected network node as a json array of objects.\n"
81 " \"id\": n, (numeric) Peer index\n"
82 " \"addr\":\"host:port\", (string) The ip address and port of the peer\n"
83 " \"addrlocal\":\"ip:port\", (string) local address\n"
84 " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n"
85 " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n"
86 " \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n"
87 " \"bytessent\": n, (numeric) The total bytes sent\n"
88 " \"bytesrecv\": n, (numeric) The total bytes received\n"
89 " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n"
90 " \"timeoffset\": ttt, (numeric) The time offset in seconds\n"
91 " \"pingtime\": n, (numeric) ping time\n"
92 " \"pingwait\": n, (numeric) ping wait\n"
93 " \"version\": v, (numeric) The peer version, such as 7001\n"
94 " \"subver\": \"/Prcycoin Core:x.x.x.x/\", (string) The string version\n"
95 " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\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"
101 " n, (numeric) The heights of blocks we're currently asking from this peer\n"
112 std::vector<CNodeStats> vstats;
113 CopyNodeStats(vstats);
150 obj.
push_back(Pair(
"inflight", heights));
162 std::string strCommand;
163 if (params.
size() == 2)
164 strCommand = params[1].
get_str();
165 if (fHelp || params.
size() != 2 ||
166 (strCommand !=
"onetry" && strCommand !=
"add" && strCommand !=
"remove"))
167 throw std::runtime_error(
168 "addnode \"node\" \"add|remove|onetry\"\n"
169 "\nAttempts add or remove a node from the addnode list.\n"
170 "Or try a connection to a node once.\n"
172 "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
173 "2. \"command\" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once\n"
177 std::string strNode = params[0].
get_str();
179 if (strCommand ==
"onetry") {
186 std::vector<std::string>::iterator it =
vAddedNodes.begin();
191 if (strCommand ==
"add") {
195 }
else if (strCommand ==
"remove") {
206 if (fHelp || params.
size() != 1)
207 throw std::runtime_error(
208 "disconnectnode \"node\" \n"
209 "\nImmediately disconnects from the specified node.\n"
211 "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
225 if (fHelp || params.
size() < 1 || params.
size() > 2)
226 throw std::runtime_error(
227 "getaddednodeinfo dummy ( \"node\" )\n"
228 "\nReturns information about the given added node, or all added nodes\n"
229 "(note that onetry addnodes are not listed here)\n"
232 "1. dummy (boolean, required) Kept for historical purposes but ignored\n"
233 "2. \"node\" (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.\n"
238 " \"addednode\" : \"192.168.0.201\", (string) The node ip address or name (as provided to addnode)\n"
239 " \"connected\" : true|false, (boolean) If connected\n"
240 " \"addresses\" : [ (list of objects) Only when connected = true\n"
242 " \"address\" : \"192.168.0.201:51472\", (string) The prcycoin server IP and port we're connected to\n"
243 " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n"
255 if (params.
size() == 2) {
258 if (info.strAddedNode == params[1].
get_str()) {
259 vInfo.assign(1, info);
273 obj.
push_back(Pair(
"addednode", info.strAddedNode));
274 obj.
push_back(Pair(
"connected", info.fConnected));
276 if (info.fConnected) {
278 address.
push_back(Pair(
"address", info.resolvedAddress.ToString()));
279 address.
push_back(Pair(
"connected", info.fInbound ?
"inbound" :
"outbound"));
282 obj.
push_back(Pair(
"addresses", addresses));
291 if (fHelp || params.
size() > 0)
292 throw std::runtime_error(
294 "\nReturns information about network traffic, including bytes in, bytes out,\n"
295 "and current time.\n"
298 " \"totalbytesrecv\": n, (numeric) Total bytes received\n"
299 " \"totalbytessent\": n, (numeric) Total bytes sent\n"
300 " \"timemillis\": t (numeric) Total cpu time\n"
315 for (
int n = 0; n <
NET_MAX; ++n) {
323 obj.push_back(Pair(
"limited",
IsLimited(network)));
324 obj.push_back(Pair(
"reachable",
IsReachable(network)));
327 networks.push_back(obj);
334 if (fHelp || params.
size() != 0)
335 throw std::runtime_error(
337 "Returns an object containing various state info regarding P2P networking.\n"
340 " \"version\": xxxxx, (numeric) the server version\n"
341 " \"subversion\": \"/Prcycoin Core:x.x.x.x/\", (string) the server subversion string\n"
342 " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
343 " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
344 " \"timeoffset\": xxxxx, (numeric) the time offset\n"
345 " \"connections\": xxxxx, (numeric) the number of connections\n"
346 " \"networks\": [ (array) information per network\n"
348 " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n"
349 " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n"
350 " \"reachable\": true|false, (boolean) is the network reachable?\n"
351 " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n"
355 " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in prcycoin/kb\n"
356 " \"localaddresses\": [ (array) list of local addresses\n"
358 " \"address\": \"xxxx\", (string) network address\n"
359 " \"port\": xxx, (numeric) network port\n"
360 " \"score\": xxx (numeric) relative score\n"
371 obj.
push_back(Pair(
"version", CLIENT_VERSION));
373 obj.
push_back(Pair(
"protocolversion", PROTOCOL_VERSION));
377 obj.
push_back(Pair(
"networks", GetNetworksInfo()));
382 for (
const std::pair<const CNetAddr, LocalServiceInfo> &item :
mapLocalHost) {
384 rec.
push_back(Pair(
"address", item.first.ToString()));
385 rec.
push_back(Pair(
"port", item.second.nPort));
386 rec.
push_back(Pair(
"score", item.second.nScore));
390 obj.
push_back(Pair(
"localaddresses", localAddresses));
396 std::string strCommand;
397 if (params.
size() >= 2)
398 strCommand = params[1].
get_str();
399 if (fHelp || params.
size() < 2 ||
400 (strCommand !=
"add" && strCommand !=
"remove"))
401 throw std::runtime_error(
402 "setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n"
403 "\nAttempts add or remove a IP/Subnet from the banned list.\n"
405 "1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n"
406 "2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n"
407 "3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the ip is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n"
408 "4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
416 bool isSubnet =
false;
417 if (params[0].get_str().find(
"/") != std::string::npos)
421 LookupHost(params[0].get_str().c_str(), resolved,
false);
428 if (strCommand ==
"add")
433 if (params.
size() >= 3 && !params[2].
isNull())
435 bool absolute =
false;
436 if (params.
size() == 4)
440 else if(strCommand ==
"remove")
451 if (fHelp || params.
size() != 0)
452 throw std::runtime_error(
454 "\nList all banned IPs/Subnets.\n"
462 for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++)
466 rec.
push_back(Pair(
"address", (*it).first.ToString()));
472 return bannedAddresses;
477 if (fHelp || params.
size() != 0)
478 throw std::runtime_error(
480 "\nClear all banned IPs.\n"
@ RPC_MISC_ERROR
General application defined errors.
UniValue disconnectnode(const UniValue ¶ms, bool fHelp)
UniValue setban(const UniValue ¶ms, bool fHelp)
std::vector< int > vHeightInFlight
std::vector< CNode * > vNodes
bool LookupSubNet(const char *pszName, CSubNet &ret)
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
UniValue getpeerinfo(const UniValue ¶ms, bool fHelp)
RecursiveMutex cs_vAddedNodes
UniValue getnetworkinfo(const UniValue ¶ms, bool fHelp)
UniValue ValueFromAmount(const CAmount &amount)
const UniValue NullUniValue
static uint64_t GetTotalBytesRecv()
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Information about a peer.
std::vector< AddedNodeInfo > GetAddedNodeInfo()
static void Ban(const CNetAddr &ip, const BanReason &banReason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
CNode * FindNode(const CNetAddr &ip)
std::string ToStringIPPort() const
UniValue ping(const UniValue ¶ms, bool fHelp)
const std::string & get_str() const
RecursiveMutex cs_main
Global state.
int64_t get_int64() const
static void GetBanned(banmap_t &banmap)
UniValue listbanned(const UniValue ¶ms, bool fHelp)
UniValue clearbanned(const UniValue ¶ms, bool fHelp)
static bool Unban(const CNetAddr &ip)
UniValue addnode(const UniValue ¶ms, bool fHelp)
bool IsReachable(enum Network net)
check whether a given network is one we can probably connect to
RecursiveMutex cs_mapLocalHost
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
UniValue JSONRPCError(int code, const std::string &message)
std::string HelpExampleRpc(std::string methodname, std::string args)
std::map< CSubNet, CBanEntry > banmap_t
std::map< CNetAddr, LocalServiceInfo > mapLocalHost
static void ClearBanned()
std::string HelpExampleCli(std::string methodname, std::string args)
UniValue getnettotals(const UniValue ¶ms, bool fHelp)
UniValue getaddednodeinfo(const UniValue ¶ms, bool fHelp)
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
A CService with information about it as peer.
static uint64_t GetTotalBytesSent()
std::string banReasonToString()
bool randomize_credentials
ServiceFlags nLocalServices
@ RPC_CLIENT_NODE_ALREADY_ADDED
Still downloading initial blocks.
void CloseSocketDisconnect()
bool IsLimited(enum Network net)
bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
bool push_back(const UniValue &val)
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
@ RPC_CLIENT_NODE_NOT_ADDED
Node is already added.
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
@ RPC_CLIENT_NODE_NOT_CONNECTED
Node has not been added before.
std::vector< std::string > vAddedNodes
std::string GetNetworkName(enum Network net)
UniValue getconnectioncount(const UniValue ¶ms, bool fHelp)
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
static bool IsBanned(CNetAddr ip)
CAmount GetFeePerK() const