From 4ef5a2216e5c2aef492ec67f2bbc2226451ef96c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 19 Oct 2016 01:27:19 -0400
Subject: [PATCH] dht: revert to previous onNewNode behavior

---
 src/dht.cpp | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/src/dht.cpp b/src/dht.cpp
index 0950bd15..6e1241c0 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -866,26 +866,12 @@ Dht::onNewNode(const std::shared_ptr<Node>& node, int confirm)
         //scheduler.edit(nextNodesConfirmation, now);
     }
 
-    unsigned expired_count = 0;
+    // Try to get rid of an expired node.
     for (auto& n : b->nodes)
-        if (n->isExpired())
-            expired_count++;
-    if (/*confirm < 2 && */b->nodes.size() - expired_count == 0) {
-        // No good or dubious node in this bucket
-        // Try to confirm this one
-        DHT_LOG_DEBUG("[node %s] Sending find node to new node.", node->toString().c_str());
-        network_engine.sendFindNode(node, list.randomId(b), -1, nullptr, nullptr);
-        if (confirm >= 2)
-            scheduler.edit(nextNodesConfirmation, scheduler.time());
-    }
-    if (expired_count > 0)  {
-        // Try to get rid of an expired node.
-        for (auto& n : b->nodes)
-            if (n->isExpired()) {
-                n = node;
-                return;
-            }
-    }
+        if (n->isExpired()) {
+            n = node;
+            return;
+        }
 
     if (b->nodes.size() >= TARGET_NODES) {
         /* Bucket full.  Ping a dubious node */
-- 
GitLab