Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1251{1252UniValue table(UniValue::VOBJ);1253for (const auto& e : tableInfos) {1254AddrInfo info = e.first;1255AddressPosition location = e.second;1256std::ostringstream key;1257key << location.bucket << "/" << location.position;1258// Address manager tables have unique entries so there is no advantage1259// in using UniValue::pushKV, which checks if the key already exists1260// in O(N). UniValue::pushKVEnd is used instead which currently is O(1).1261table.pushKVEnd(key.str(), AddrmanEntryToJSON(info, connman));1262}1263return table;1264}1266static RPCMethod getrawaddrman()1267{1268return RPCMethod{"getrawaddrman",1269"EXPERIMENTAL warning: this call may be changed in future releases.\n"1270"\nReturns information on all address manager entries for the new and tried tables.\n",1271{},1272RPCResult{1273RPCResult::Type::OBJ_DYN, "", "", {1274{RPCResult::Type::OBJ_DYN, "table", "buckets with addresses in the address manager table ( new, tried )", {1275{RPCResult::Type::OBJ, "bucket/position", "the location in the address manager table (<bucket>/<position>)", {1276{RPCResult::Type::STR, "address", "The address of the node"},1277{RPCResult::Type::NUM, "mapped_as", /*optional=*/true, "Mapped AS (Autonomous System) number at the end of the BGP route to the peer, used for diversifying peer selection (only displayed if the -asmap config option is set)"},1278{RPCResult::Type::NUM, "port", "The port number of the node"},1279{RPCResult::Type::STR, "network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the address"},1280{RPCResult::Type::NUM, "services", "The services offered by the node"},1281{RPCResult::Type::NUM_TIME, "time", "The " + UNIX_EPOCH_TIME + " when the node was last seen"},1282{RPCResult::Type::STR, "source", "The address that relayed the address to us"},1283{RPCResult::Type::STR, "source_network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the source address"},1284{RPCResult::Type::NUM, "source_mapped_as", /*optional=*/true, "Mapped AS (Autonomous System) number at the end of the BGP route to the source, used for diversifying peer selection (only displayed if the -asmap config option is set)"}1285}}1286}}1287}1288},1289RPCExamples{1290HelpExampleCli("getrawaddrman", "")1291+ HelpExampleRpc("getrawaddrman", "")1292},1293[](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue {1294AddrMan& addrman = EnsureAnyAddrman(request.context);1295NodeContext& node_context = EnsureAnyNodeContext(request.context);1296CConnman& connman = EnsureConnman(node_context);1298UniValue ret(UniValue::VOBJ);1299ret.pushKV("new", AddrmanTableToJSON(addrman.GetEntries(false), connman));1300ret.pushKV("tried", AddrmanTableToJSON(addrman.GetEntries(true), connman));1301return ret;1302},1303};1304}1306void RegisterNetRPCCommands(CRPCTable& t)1307{1308static const CRPCCommand commands[]{1309{"network", &getconnectioncount},1310{"network", &ping},1311{"network", &getpeerinfo},1312{"network", &addnode},1313{"network", &disconnectnode},1314{"network", &getaddednodeinfo},1315{"network", &getnettotals},1316{"network", &getnetworkinfo},1317{"network", &setban},1318{"network", &listbanned},1319{"network", &clearbanned},1320{"network", &setnetworkactive},1321{"network", &getnodeaddresses},1322{"network", &getaddrmaninfo},1323{"network", &exportasmap},1324{"hidden", &addconnection},1325{"hidden", &addpeeraddress},1326{"hidden", &sendmsgtopeer},1327{"hidden", &getrawaddrman},1328};1329for (const auto& c : commands) {1330t.appendCommand(c.name, &c);1331}1332}