From daa2ae1f6ad041a8be8ef2b9344daae1c0037d99 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Fri, 6 Oct 2023 13:17:23 -0400 Subject: [PATCH] Router: Comment isClientDb() and isMultihomeDb() checks in KNDF so they're less confusing to look at --- .../networkdb/kademlia/FloodfillNetworkDatabaseFacade.java | 2 +- .../networkdb/kademlia/KademliaNetworkDatabaseFacade.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 3e0bc0e323..cffc1f16a9 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java @@ -126,7 +126,7 @@ public synchronized void startup() { @Override protected void createHandlers() { // Only initialize the handlers for the flooodfill netDb. - if (super._dbid == FloodfillNetworkDatabaseSegmentor.MAIN_DBID) { + if (!isClientDb()) { if (_log.shouldInfo()) _log.info("[dbid: " + super._dbid + "] Initializing the message handlers"); _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseLookupMessage.MESSAGE_TYPE, new FloodfillDatabaseLookupMessageHandler(_context, this)); 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 cefcb37f55..3726eed81d 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -307,6 +307,8 @@ String getDbDir() { } public boolean isClientDb() { + // This is a null check in disguise, don't use .equals() here. + // FNDS.MAIN_DBID is always null. and if _dbid is also null it is not a client Db if (_dbid == FloodfillNetworkDatabaseSegmentor.MAIN_DBID) return false; if (_dbid.equals(FloodfillNetworkDatabaseSegmentor.MULTIHOME_DBID)) @@ -315,6 +317,8 @@ public boolean isClientDb() { } public boolean isMultihomeDb() { + // This is a null check in disguise, don't use .equals() here. + // FNDS.MAIN_DBID is always null, and if _dbid is null it is not the multihome Db if (_dbid == FloodfillNetworkDatabaseSegmentor.MAIN_DBID) return false; if (_dbid.equals(FloodfillNetworkDatabaseSegmentor.MULTIHOME_DBID))