From f7424b8bbec61797289fed9a3b56e77d332a1fb5 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 19 Feb 2021 17:19:21 -0500 Subject: [PATCH] dont use std::optional --- llarp/config/config.cpp | 17 +++++++---------- llarp/config/config.hpp | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index cf4ba1735..4d9ceb5e3 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -1022,19 +1022,16 @@ namespace llarp bool PeerSelectionConfig::Acceptable(const std::set& rcs) const { - if (m_UniqueHopsNetmaskSize) + const auto netmask = netmask_ipv6_bits(96 + m_UniqueHopsNetmaskSize); + std::set seenRanges; + for (const auto& hop : rcs) { - const auto netmask = netmask_ipv6_bits(96 + *m_UniqueHopsNetmaskSize); - std::set seenRanges; - for (const auto& hop : rcs) + for (const auto& addr : hop.addrs) { - for (const auto& addr : hop.addrs) + const auto network_addr = net::In6ToHUInt(addr.ip) & netmask; + if (auto [it, inserted] = seenRanges.emplace(network_addr, netmask); not inserted) { - const auto network_addr = net::In6ToHUInt(addr.ip) & netmask; - if (auto [it, inserted] = seenRanges.emplace(network_addr, netmask); not inserted) - { - return false; - } + return false; } } } diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index cecf47d48..b7ef4f64c 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -77,7 +77,7 @@ namespace llarp /// in our hops what netmask will we use for unique ips for hops /// i.e. 32 for every hop unique ip, 24 unique /24 per hop, etc /// - std::optional m_UniqueHopsNetmaskSize; + int m_UniqueHopsNetmaskSize; /// set of countrys to exclude from path building (2 char country code) std::unordered_set m_ExcludeCountries;