From e1dd7ad97f93786c0764bb16d625d0d42df1a5e3 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 29 Jul 2019 18:33:49 -0400 Subject: [PATCH] revert dht stuff --- llarp/dht/bucket.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/llarp/dht/bucket.hpp b/llarp/dht/bucket.hpp index a0998e052..d796bc480 100644 --- a/llarp/dht/bucket.hpp +++ b/llarp/dht/bucket.hpp @@ -108,8 +108,8 @@ namespace llarp return true; } - const size_t expecting = N; - const size_t sz = nodes.size(); + size_t expecting = N; + size_t sz = nodes.size(); while(N) { auto itr = nodes.begin(); @@ -137,7 +137,7 @@ namespace llarp continue; } - const auto curDist = item.first ^ target; + auto curDist = item.first ^ target; if(curDist < mindist) { mindist = curDist; @@ -151,16 +151,17 @@ namespace llarp GetManyNearExcluding(const Key_t& target, std::set< Key_t >& result, size_t N, const std::set< Key_t >& exclude) const { - auto itr = nodes.lower_bound(target); - const auto end = nodes.end(); - while(N > 0 && itr != end) + std::set< Key_t > s(exclude.begin(), exclude.end()); + + Key_t peer; + while(N--) { - if(exclude.count(itr->first) == 0) + if(!FindCloseExcluding(target, peer, s)) { - result.insert(itr->first); - --N; + return false; } - ++itr; + s.insert(peer); + result.insert(peer); } return true; }