From 7165dc786025d5b5e6bea6ec01edf94f25b8285b Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sun, 1 Feb 2015 19:57:18 +0000
Subject: [PATCH] NetDB: Don't flood an RI back to itself. While Java ffs
 self-flood, other implementations may not.

---
 .../kademlia/FloodfillNetworkDatabaseFacade.java     | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
index 9358092260..8b603776f0 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
@@ -191,6 +191,11 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
             List<Hash> nextPeers = sel.selectFloodfillParticipants(nkey, NEXT_FLOOD_QTY, getKBuckets());
             int i = 0;
             for (Hash h : nextPeers) {
+                // Don't flood an RI back to itself
+                // Not necessary, a ff will do its own flooding (reply token == 0)
+                // But other implementations may not...
+                if (h.equals(key))
+                    continue;
                 // todo key cert skip?
                 if (!peers.contains(h)) {
                     peers.add(h);
@@ -206,10 +211,11 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
             RouterInfo target = lookupRouterInfoLocally(peer);
             if ( (target == null) || (_context.banlist().isBanlisted(peer)) )
                 continue;
-            // Don't flood a RI back to itself
+            // Don't flood an RI back to itself
             // Not necessary, a ff will do its own flooding (reply token == 0)
-            //if (peer.equals(target.getIdentity().getHash()))
-            //    continue;
+            // But other implementations may not...
+            if (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO && peer.equals(key))
+                continue;
             if (peer.equals(_context.routerHash()))
                 continue;
             DatabaseStoreMessage msg = new DatabaseStoreMessage(_context);
-- 
GitLab