mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
cli -addrinfo: drop torv2, torv3 becomes onion per GetNetworkName()
This commit is contained in:
parent
2aa937e97a
commit
75ea9ecf11
1 changed files with 2 additions and 5 deletions
|
@ -245,7 +245,7 @@ public:
|
||||||
class AddrinfoRequestHandler : public BaseRequestHandler
|
class AddrinfoRequestHandler : public BaseRequestHandler
|
||||||
{
|
{
|
||||||
private:
|
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
|
int8_t NetworkStringToId(const std::string& str) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_networks.size(); ++i) {
|
for (size_t i = 0; i < m_networks.size(); ++i) {
|
||||||
|
@ -271,13 +271,10 @@ public:
|
||||||
if (!nodes.empty() && nodes.at(0)["network"].isNull()) {
|
if (!nodes.empty() && nodes.at(0)["network"].isNull()) {
|
||||||
throw std::runtime_error("-addrinfo requires bitcoind server to be running v22.0 and up");
|
throw std::runtime_error("-addrinfo requires bitcoind server to be running v22.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{{}};
|
std::array<uint64_t, m_networks.size()> counts{{}};
|
||||||
for (const UniValue& node : nodes) {
|
for (const UniValue& node : nodes) {
|
||||||
std::string network_name{node["network"].get_str()};
|
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)};
|
const int8_t network_id{NetworkStringToId(network_name)};
|
||||||
if (network_id == UNKNOWN_NETWORK) continue;
|
if (network_id == UNKNOWN_NETWORK) continue;
|
||||||
++counts.at(network_id);
|
++counts.at(network_id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue