From 284bdcb67bad7906ba45aa339a068bc9142c81ed Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Tue, 17 Oct 2023 14:29:31 -0400 Subject: [PATCH] Router: bypass the negative cache when the db is a subdb --- .../KademliaNetworkDatabaseFacade.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index e3d23dbd9b..7b6e7b51cd 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -386,9 +386,10 @@ public synchronized void startup() { } catch (IOException ioe) { throw new RuntimeException("Unable to initialize netdb storage", ioe); } - _negativeCache = new NegativeLookupCache(_context); - if (isMainDb()) + if (isMainDb()) { + _negativeCache = new NegativeLookupCache(_context); blindCache().startup(); + } createHandlers(); @@ -802,7 +803,8 @@ public Destination lookupDestinationLocally(Hash key) { return ls.getDestination(); } } else { - return _negativeCache.getBadDest(key); + if (_negativeCache != null) + return _negativeCache.getBadDest(key); } return null; } @@ -1514,7 +1516,8 @@ protected void lookupBeforeDropping(Hash peer, RouterInfo info) { */ void dropAfterLookupFailed(Hash peer) { _context.peerManager().removeCapabilities(peer); - _negativeCache.cache(peer); + if (_negativeCache != null) + _negativeCache.cache(peer); _kb.remove(peer); //if (removed) { // if (_log.shouldLog(Log.INFO)) @@ -1656,7 +1659,8 @@ else if (responseTime < MIN_PER_PEER_TIMEOUT) * @since 0.9.4 moved from FNDF to KNDF in 0.9.16 */ void lookupFailed(Hash key) { - _negativeCache.lookupFailed(key); + if (_negativeCache != null) + _negativeCache.lookupFailed(key); } /** @@ -1666,6 +1670,8 @@ void lookupFailed(Hash key) { * @since 0.9.4 moved from FNDF to KNDF in 0.9.16 */ boolean isNegativeCached(Hash key) { + if (_negativeCache == null) + return false; boolean rv = _negativeCache.isCached(key); if (rv) _context.statManager().addRateData("netDb.negativeCache", 1); @@ -1677,6 +1683,8 @@ boolean isNegativeCached(Hash key) { * @since 0.9.16 */ void failPermanently(Destination dest) { + if (_negativeCache != null) + return; _negativeCache.failPermanently(dest); } @@ -1687,6 +1695,8 @@ void failPermanently(Destination dest) { * @since 0.9.16 */ public boolean isNegativeCachedForever(Hash key) { + if (_negativeCache != null) + return false; return _negativeCache.getBadDest(key) != null; }