Skip to content

Commit 28ce159

Browse files
committed
Merge bitcoin/bitcoin#30183: rpc: net: follow-ups for #30062
a16917f rpc, net: improve `mapped_as` doc for getrawaddrman/getpeerinfo (brunoerg) bdad024 rpc, net: getrawaddrman "mapped_as" follow-ups (brunoerg) Pull request description: - Change `addrman` to reference to const since it isn't modified (bitcoin/bitcoin#30062 (comment)). - Improve documentation of `mapped_as`/`source_mapped_as` in `getrawaddrman` RPC by mentioning that both fields will be only available if asmap flag is set. It is the same message for `mapped_as` field in `getpeerinfo`. ACKs for top commit: fjahr: re-ACK a16917f 0xB10C: re-ACK a16917f laanwj: re-ACK a16917f Tree-SHA512: c66b2ee9d24da93d443be83f6ef3b2d39fd5bf3f73e2974574cad238ffb82035704cf4fbf1bac22a63734948e285e8e091c2884bb640202efdb473315e770233
2 parents 6848739 + a16917f commit 28ce159

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/bitcoin-cli.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
678678
" \".\" - we do not relay addresses to this peer (addr_relay_enabled is false)\n"
679679
" addrl Total number of addresses dropped due to rate limiting\n"
680680
" age Duration of connection to the peer, in minutes\n"
681-
" asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying\n"
681+
" asmap Mapped AS (Autonomous System) number at the end of the BGP route to the peer, used for diversifying\n"
682682
" peer selection (only displayed if the -asmap config option is set)\n"
683683
" id Peer index, in increasing order of peer connections since node startup\n"
684684
" address IP address and port of the peer\n"

src/rpc/net.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ static RPCHelpMan getpeerinfo()
129129
{RPCResult::Type::STR, "addrbind", /*optional=*/true, "(ip:port) Bind address of the connection to the peer"},
130130
{RPCResult::Type::STR, "addrlocal", /*optional=*/true, "(ip:port) Local address as reported by the peer"},
131131
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/*append_unroutable=*/true), ", ") + ")"},
132-
{RPCResult::Type::NUM, "mapped_as", /*optional=*/true, "The AS in the BGP route to the peer used for diversifying\n"
133-
"peer selection (only available if the asmap config flag is set)"},
132+
{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\n"
133+
"peer selection (only displayed if the -asmap config option is set)"},
134134
{RPCResult::Type::STR_HEX, "services", "The services offered"},
135135
{RPCResult::Type::ARR, "servicesnames", "the services offered, in human-readable form",
136136
{
@@ -1102,12 +1102,12 @@ static RPCHelpMan getaddrmaninfo()
11021102
};
11031103
}
11041104

1105-
UniValue AddrmanEntryToJSON(const AddrInfo& info, CConnman& connman)
1105+
UniValue AddrmanEntryToJSON(const AddrInfo& info, const CConnman& connman)
11061106
{
11071107
UniValue ret(UniValue::VOBJ);
11081108
ret.pushKV("address", info.ToStringAddr());
1109-
const auto mapped_as{connman.GetMappedAS(info)};
1110-
if (mapped_as != 0) {
1109+
const uint32_t mapped_as{connman.GetMappedAS(info)};
1110+
if (mapped_as) {
11111111
ret.pushKV("mapped_as", mapped_as);
11121112
}
11131113
ret.pushKV("port", info.GetPort());
@@ -1116,14 +1116,14 @@ UniValue AddrmanEntryToJSON(const AddrInfo& info, CConnman& connman)
11161116
ret.pushKV("network", GetNetworkName(info.GetNetClass()));
11171117
ret.pushKV("source", info.source.ToStringAddr());
11181118
ret.pushKV("source_network", GetNetworkName(info.source.GetNetClass()));
1119-
const auto source_mapped_as{connman.GetMappedAS(info.source)};
1120-
if (source_mapped_as != 0) {
1119+
const uint32_t source_mapped_as{connman.GetMappedAS(info.source)};
1120+
if (source_mapped_as) {
11211121
ret.pushKV("source_mapped_as", source_mapped_as);
11221122
}
11231123
return ret;
11241124
}
11251125

1126-
UniValue AddrmanTableToJSON(const std::vector<std::pair<AddrInfo, AddressPosition>>& tableInfos, CConnman& connman)
1126+
UniValue AddrmanTableToJSON(const std::vector<std::pair<AddrInfo, AddressPosition>>& tableInfos, const CConnman& connman)
11271127
{
11281128
UniValue table(UniValue::VOBJ);
11291129
for (const auto& e : tableInfos) {
@@ -1150,14 +1150,14 @@ static RPCHelpMan getrawaddrman()
11501150
{RPCResult::Type::OBJ_DYN, "table", "buckets with addresses in the address manager table ( new, tried )", {
11511151
{RPCResult::Type::OBJ, "bucket/position", "the location in the address manager table (<bucket>/<position>)", {
11521152
{RPCResult::Type::STR, "address", "The address of the node"},
1153-
{RPCResult::Type::NUM, "mapped_as", /*optional=*/true, "The ASN mapped to the IP of this peer per our current ASMap"},
1153+
{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)"},
11541154
{RPCResult::Type::NUM, "port", "The port number of the node"},
11551155
{RPCResult::Type::STR, "network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the address"},
11561156
{RPCResult::Type::NUM, "services", "The services offered by the node"},
11571157
{RPCResult::Type::NUM_TIME, "time", "The " + UNIX_EPOCH_TIME + " when the node was last seen"},
11581158
{RPCResult::Type::STR, "source", "The address that relayed the address to us"},
11591159
{RPCResult::Type::STR, "source_network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the source address"},
1160-
{RPCResult::Type::NUM, "source_mapped_as", /*optional=*/true, "The ASN mapped to the IP of this peer's source per our current ASMap"}
1160+
{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)"}
11611161
}}
11621162
}}
11631163
}

0 commit comments

Comments
 (0)