MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / getaddednodeinfo

Function getaddednodeinfo

src/rpc/net.cpp:533–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532
533static RPCHelpMan getaddednodeinfo() {
534 return RPCHelpMan{
535 "getaddednodeinfo",
536 "Returns information about the given added node, or all added nodes\n"
537 "(note that onetry addnodes are not listed here)\n",
538 {
539 {"node", RPCArg::Type::STR, RPCArg::DefaultHint{"all nodes"},
540 "If provided, return information about this specific node, "
541 "otherwise all nodes are returned."},
542 },
543 RPCResult{
544 RPCResult::Type::ARR,
545 "",
546 "",
547 {
548 {RPCResult::Type::OBJ,
549 "",
550 "",
551 {
552 {RPCResult::Type::STR, "addednode",
553 "The node IP address or name (as provided to addnode)"},
554 {RPCResult::Type::BOOL, "connected", "If connected"},
555 {RPCResult::Type::ARR,
556 "addresses",
557 "Only when connected = true",
558 {
559 {RPCResult::Type::OBJ,
560 "",
561 "",
562 {
563 {RPCResult::Type::STR, "address",
564 "The bitcoin server IP and port we're "
565 "connected to"},
566 {RPCResult::Type::STR, "connected",
567 "connection, inbound or outbound"},
568 }},
569 }},
570 }},
571 }},
572 RPCExamples{HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"") +
573 HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"")},
574 [&](const RPCHelpMan &self, const Config &config,
575 const JSONRPCRequest &request) -> UniValue {
576 NodeContext &node = EnsureAnyNodeContext(request.context);
577 const CConnman &connman = EnsureConnman(node);
578
579 std::vector<AddedNodeInfo> vInfo = connman.GetAddedNodeInfo();
580
581 if (!request.params[0].isNull()) {
582 bool found = false;
583 for (const AddedNodeInfo &info : vInfo) {
584 if (info.strAddedNode == request.params[0].get_str()) {
585 vInfo.assign(1, info);
586 found = true;
587 break;
588 }
589 }
590 if (!found) {

Callers

nothing calls this directly

Calls 9

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
GetAddedNodeInfoMethod · 0.80
isNullMethod · 0.80
pushKVMethod · 0.80
ToStringAddrPortMethod · 0.80
assignMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected