From d6aaf3ee3a1518acecb741a01d88ca18d3d4b5e6 Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Thu, 28 Apr 2022 10:49:13 -0400
Subject: [PATCH] NTCP: Don't flood RI block unless newer

Don't accept store of our RI in RI block
---
 .../src/net/i2p/router/transport/ntcp/NTCPConnection.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
index 394c2db886..2ad8163ae8 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
@@ -1641,10 +1641,13 @@ public class NTCPConnection implements Closeable {
             _messagesRead.incrementAndGet();
             try {
                 Hash h = ri.getHash();
+                if (h.equals(_context.routerHash()))
+                    return;
                 RouterInfo old = _context.netDb().store(h, ri);
                 if (flood && !ri.equals(old)) {
                     FloodfillNetworkDatabaseFacade fndf = (FloodfillNetworkDatabaseFacade) _context.netDb();
-                    if (fndf.floodConditional(ri)) {
+                    if ((old == null || ri.getPublished() > old.getPublished()) &&
+                        fndf.floodConditional(ri)) {
                         if (_log.shouldDebug())
                             _log.debug("Flooded the RI: " + h);
                     } else {
@@ -1653,7 +1656,8 @@ public class NTCPConnection implements Closeable {
                     }
                 }
             } catch (IllegalArgumentException iae) {
-                throw new DataFormatException("RI store fail: " + ri, iae);
+                if (_log.shouldWarn())
+                    _log.warn("RI store fail: " + ri, iae);
             }
         }
 
-- 
GitLab