From fa24e11b141dfab7b83ded9d695fb1f92af093d2 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Tue, 19 Sep 2023 21:03:22 -0400 Subject: [PATCH] Router: re-create multihomeNetDb functionality on top of new SNDF API --- .../HandleFloodfillDatabaseStoreMessageJob.java | 11 +---------- .../networkdb/kademlia/PersistentDataStore.java | 6 ++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/HandleFloodfillDatabaseStoreMessageJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/HandleFloodfillDatabaseStoreMessageJob.java index d1eb150533..ea37d12757 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/HandleFloodfillDatabaseStoreMessageJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/HandleFloodfillDatabaseStoreMessageJob.java @@ -155,16 +155,7 @@ else if (getContext().clientManager().isLocal(key)) getContext().statManager().addRateData("netDb.storeLocalLeaseSetAttempt", 1, 0); // throw rather than return, so that we send the ack below (prevent easy attack) dontBlamePeer = true; - // store the peer in the outboundCache instead so that we can reply back with it without confusing ourselves. - if (ls.isCurrent(Router.CLOCK_FUDGE_FACTOR / 4)) { - if (_facade.validate(key, ls) == null) { - LeaseSet compareLeasesetDate = getContext().clientMessagePool().getCache().multihomedCache.get(key); - if (compareLeasesetDate == null) - getContext().clientMessagePool().getCache().multihomedCache.put(key, ls); - else if (compareLeasesetDate.getEarliestLeaseDate() < ls.getEarliestLeaseDate()) - getContext().clientMessagePool().getCache().multihomedCache.put(key, ls); - } - } + getContext().multihomeNetDb().store(key, ls); throw new IllegalArgumentException("(dbid: " + _facade._dbid + ") Peer attempted to store local leaseSet: " + key.toBase32()); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java index 3d0f07e98c..7214e545ba 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java @@ -483,6 +483,10 @@ private void readFiles() { _lastReseed = _context.clock().now(); _setNetDbReady = true; setNetDbReady(); + } else if (_facade.isMultihomeDb()) { + _lastReseed = _context.clock().now(); + _setNetDbReady = true; + setNetDbReady(); } else if (_facade.reseedChecker().checkReseed(routerCount)) { _lastReseed = _context.clock().now(); // checkReseed will call wakeup() when done and we will run again @@ -494,6 +498,8 @@ private void readFiles() { int count = Math.min(routerCount, size()); if (_facade.isClientDb()) { _lastReseed = _context.clock().now(); + } else if (_facade.isMultihomeDb()) { + _lastReseed = _context.clock().now(); } else if (count < MIN_ROUTERS) { if (_facade.reseedChecker().checkReseed(count)) _lastReseed = _context.clock().now();