From fb8bb645c2414dd29846b283196c859fcca94210 Mon Sep 17 00:00:00 2001
From: eyedeekay <idk@mulder>
Date: Mon, 16 Oct 2023 20:47:27 -0400
Subject: [PATCH] Router: move getReceivedBy and getReceivedAsPublished into
 DatabaseEntry

---
 core/java/src/net/i2p/data/DatabaseEntry.java | 23 +++++++++++++++++--
 core/java/src/net/i2p/data/LeaseSet.java      | 15 +++---------
 core/java/src/net/i2p/data/LeaseSet2.java     |  2 +-
 .../src/net/i2p/data/router/RouterInfo.java   | 13 -----------
 4 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/core/java/src/net/i2p/data/DatabaseEntry.java b/core/java/src/net/i2p/data/DatabaseEntry.java
index 8af4fdcb08..5f75a37b10 100644
--- a/core/java/src/net/i2p/data/DatabaseEntry.java
+++ b/core/java/src/net/i2p/data/DatabaseEntry.java
@@ -62,8 +62,27 @@ public abstract class DatabaseEntry extends DataStructureImpl {
     // synch: this
     private Hash _currentRoutingKey;
     private long _routingKeyGenMod;
-    protected boolean _receivedAsPublished;
-    protected boolean _receivedAsReply;
+    private boolean _receivedAsPublished;
+    private boolean _receivedAsReply;
+
+    /**
+     * Hash of the client receiving the routerinfo, or null if it was sent directly.
+     */
+    private Hash _receivedBy;
+
+    /**
+     * The Hash of the local client that received this LS,
+     * null if the router or unknown.
+     *
+     * @since 0.9.47
+     */
+    public Hash getReceivedBy() {
+        return _receivedBy;
+    }
+
+    public void setReceivedBy(Hash receivedBy) {
+        this._receivedBy = receivedBy;
+    }
 
     /**
      * A common interface to the timestamp of the two subclasses.
diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java
index 96159b4437..d16101705a 100644
--- a/core/java/src/net/i2p/data/LeaseSet.java
+++ b/core/java/src/net/i2p/data/LeaseSet.java
@@ -68,7 +68,6 @@ public class LeaseSet extends DatabaseEntry {
     protected SigningPublicKey _signingKey;
     // Keep leases in the order received, or else signature verification will fail!
     protected final List<Lease> _leases;
-    private Hash _receivedBy;
     // Store these since isCurrent() and getEarliestLeaseDate() are called frequently
     private long _firstExpiration;
     protected long _lastExpiration;
@@ -185,22 +184,14 @@ public class LeaseSet extends DatabaseEntry {
         _signingKey = key;
     }
 
-    /**
-     * The Hash of the local client that received this LS,
-     * null if the router or unknown.
-     *
-     * @since 0.9.47
-     */
-    public Hash getReceivedBy() { return _receivedBy; }
-
     /**
      * Also sets receivedAsReply to true
      * @param localClient may be null
      * @since 0.9.47
      */
     public void setReceivedBy(Hash localClient) {
-        _receivedAsReply = true;
-        _receivedBy = localClient;
+        super.setReceivedBy(localClient);
+        super.setReceivedAsReply();
     }
 
     /**
@@ -331,7 +322,7 @@ public class LeaseSet extends DatabaseEntry {
         }
         byte rv[] = out.toByteArray();
         // if we are floodfill and this was published to us
-        if (_receivedAsPublished)
+        if (getReceivedAsPublished())
             _byteified = rv;
         return rv;
     }
diff --git a/core/java/src/net/i2p/data/LeaseSet2.java b/core/java/src/net/i2p/data/LeaseSet2.java
index 9888b30f6f..561803442e 100644
--- a/core/java/src/net/i2p/data/LeaseSet2.java
+++ b/core/java/src/net/i2p/data/LeaseSet2.java
@@ -396,7 +396,7 @@ public class LeaseSet2 extends LeaseSet {
         }
         byte rv[] = out.toByteArray();
         // if we are floodfill and this was published to us
-        if (_receivedAsPublished)
+        if (getReceivedAsPublished())
             _byteified = rv;
         return rv;
     }
diff --git a/router/java/src/net/i2p/data/router/RouterInfo.java b/router/java/src/net/i2p/data/router/RouterInfo.java
index 0ed5e2da0c..ba556a7271 100644
--- a/router/java/src/net/i2p/data/router/RouterInfo.java
+++ b/router/java/src/net/i2p/data/router/RouterInfo.java
@@ -86,19 +86,6 @@ public class RouterInfo extends DatabaseEntry {
     public static final String PROP_CAPABILITIES = "caps";
     public static final char CAPABILITY_HIDDEN = 'H';
     private static final int MAX_ADDRESSES = 16;
-    
-    /**
-     * Hash of the client receiving the routerinfo, or null if it was sent directly.
-     */
-    private Hash _receivedBy;
-
-    public Hash getReceivedBy() {
-        return _receivedBy;
-    }
-
-    public void setReceivedBy(Hash _receivedBy) {
-        this._receivedBy = _receivedBy;
-    }
 
     /** Public string of chars which serve as bandwidth capacity markers
      * NOTE: individual chars defined in Router.java
-- 
GitLab