MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / getaddednodeinfo

Function getaddednodeinfo

src/rpc/rpcnet.cpp:350–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350Value getaddednodeinfo(const Array& params, bool fHelp) {
351 if (fHelp || params.size() < 1 || params.size() > 2)
352 throw runtime_error(
353 "getaddednodeinfo \"dns\" [\"node\"]\n"
354 "\nReturns information about the given added node, or all added nodes\n"
355 "(note that onetry addnodes are not listed here)\n"
356 "If dns is false, only a list of added nodes will be provided,\n"
357 "otherwise connected information will also be available.\n"
358 "\nArguments:\n"
359 "1.\"dns\" (boolean, required) If false, only a list of added nodes will be provided, otherwise "
360 "connected information will also be available.\n"
361 "2.\"node\" (string, optional) If provided, return information about this specific node, otherwise all "
362 "nodes are returned.\n"
363 "\nResult:\n"
364 "[\n"
365 " {\n"
366 " \"addednode\" : \"192.168.0.201\", (string) The node ip address\n"
367 " \"connected\" : true|false, (boolean) If connected\n"
368 " \"addresses\" : [\n"
369 " {\n"
370 " \"address\" : \"192.168.0.201:8333\", (string) The Coin server host and port\n"
371 " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n"
372 " }\n"
373 " ,...\n"
374 " ]\n"
375 " }\n"
376 " ,...\n"
377 "]\n"
378 "\nExamples:\n" +
379 HelpExampleCli("getaddednodeinfo", "true \"192.168.0.201\"") + "\nAs json rpc\n" +
380 HelpExampleRpc("getaddednodeinfo", "true, \"192.168.0.201\""));
381
382 bool fDns = params[0].get_bool();
383
384 list<string> addedNodes;
385 if (params.size() == 1) {
386 LOCK(cs_vAddedNodes);
387 for (auto& strAddNode : vAddedNodes)
388 addedNodes.push_back(strAddNode);
389 } else {
390 string strNode = params[1].get_str();
391 LOCK(cs_vAddedNodes);
392 for (auto& strAddNode : vAddedNodes)
393 if (strAddNode == strNode) {
394 addedNodes.push_back(strAddNode);
395 break;
396 }
397 if (addedNodes.size() == 0)
398 throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
399 }
400
401 Array ret;
402 if (!fDns) {
403 for (auto& strAddNode : addedNodes) {
404 Object obj;
405 obj.push_back(Pair("addednode", strAddNode));
406 ret.push_back(obj);
407 }

Callers

nothing calls this directly

Calls 12

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
PairClass · 0.85
LookupFunction · 0.85
get_boolMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45
GetDefaultPortMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected