merge bitcoin#22544: drop torv2; torv3 becomes onion per GetNetworkName()

This commit is contained in:
Kittywhiskers Van Gogh 2024-05-26 21:26:41 +00:00
parent b6ca36edda
commit 30b0fcf4a6
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
3 changed files with 11 additions and 9 deletions

View File

@ -0,0 +1,6 @@
Tools and Utilities
-------------------
- CLI `-addrinfo` now returns a single field for the number of `onion` addresses
known to the node instead of separate `torv2` and `torv3` fields, as support
for Tor V2 addresses was removed from Dash Core in 18.0.

View File

@ -18,10 +18,9 @@ There are several ways to see your local onion address in Dash Core:
You may set the `-debug=tor` config logging option to have additional
information in the debug log about your Tor configuration.
CLI `-addrinfo` returns the number of addresses known to your node per network
type, including Tor v2 and v3. This is useful to see how many onion addresses
are known to your node for `-onlynet=onion` and how many Tor v3 addresses it
knows when upgrading to current and future Tor releases that support Tor v3 only.
CLI `-addrinfo` returns the number of addresses known to your node per
network. This can be useful to see how many onion peers your node knows,
e.g. for `-onlynet=onion`.
## 1. Run Dash Core behind a Tor proxy

View File

@ -259,7 +259,7 @@ public:
class AddrinfoRequestHandler : public BaseRequestHandler
{
private:
static constexpr std::array m_networks{"ipv4", "ipv6", "torv2", "torv3", "i2p"};
static constexpr std::array m_networks{"ipv4", "ipv6", "onion", "i2p"};
int8_t NetworkStringToId(const std::string& str) const
{
for (size_t i = 0; i < m_networks.size(); ++i) {
@ -285,13 +285,10 @@ public:
if (!nodes.empty() && nodes.at(0)["network"].isNull()) {
throw std::runtime_error("-addrinfo requires dashd server to be running v21.0 and up");
}
// Count the number of peers we know by network, including torv2 versus torv3.
// Count the number of peers known to our node, by network.
std::array<uint64_t, m_networks.size()> counts{{}};
for (const UniValue& node : nodes) {
std::string network_name{node["network"].get_str()};
if (network_name == "onion") {
network_name = node["address"].get_str().size() > 22 ? "torv3" : "torv2";
}
const int8_t network_id{NetworkStringToId(network_name)};
if (network_id == UNKNOWN_NETWORK) continue;
++counts.at(network_id);