MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getaddrmaninfo

Function getaddrmaninfo

src/rpc/net.cpp:1092–1129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090}
1091
1092static RPCMethod getaddrmaninfo()
1093{
1094 return RPCMethod{
1095 "getaddrmaninfo",
1096 "Provides information about the node's address manager by returning the number of "
1097 "addresses in the `new` and `tried` tables and their sum for all networks.\n",
1098 {},
1099 RPCResult{
1100 RPCResult::Type::OBJ_DYN, "", "json object with network type as keys", {
1101 {RPCResult::Type::OBJ, "network", "the network (" + Join(GetNetworkNames(), ", ") + ", all_networks)", {
1102 {RPCResult::Type::NUM, "new", "number of addresses in the new table, which represent potential peers the node has discovered but hasn't yet successfully connected to."},
1103 {RPCResult::Type::NUM, "tried", "number of addresses in the tried table, which represent peers the node has successfully connected to in the past."},
1104 {RPCResult::Type::NUM, "total", "total number of addresses in both new/tried tables"},
1105 }},
1106 }},
1107 RPCExamples{HelpExampleCli("getaddrmaninfo", "") + HelpExampleRpc("getaddrmaninfo", "")},
1108 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue {
1109 AddrMan& addrman = EnsureAnyAddrman(request.context);
1110
1111 UniValue ret(UniValue::VOBJ);
1112 for (int n = 0; n < NET_MAX; ++n) {
1113 enum Network network = static_cast<enum Network>(n);
1114 if (network == NET_UNROUTABLE || network == NET_INTERNAL) continue;
1115 UniValue obj(UniValue::VOBJ);
1116 obj.pushKV("new", addrman.Size(network, true));
1117 obj.pushKV("tried", addrman.Size(network, false));
1118 obj.pushKV("total", addrman.Size(network));
1119 ret.pushKV(GetNetworkName(network), std::move(obj));
1120 }
1121 UniValue obj(UniValue::VOBJ);
1122 obj.pushKV("new", addrman.Size(std::nullopt, true));
1123 obj.pushKV("tried", addrman.Size(std::nullopt, false));
1124 obj.pushKV("total", addrman.Size());
1125 ret.pushKV("all_networks", std::move(obj));
1126 return ret;
1127 },
1128 };
1129}
1130
1131static RPCMethod exportasmap()
1132{

Callers

nothing calls this directly

Calls 7

JoinFunction · 0.85
GetNetworkNamesFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
GetNetworkNameFunction · 0.85
pushKVMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected