From 78ee005870089b6fae10a4785b6ef05685591d61 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 11 Feb 2023 09:47:40 -0500 Subject: [PATCH] Data: Move LS RAP/RAR booleans up to superclass Add RAR to I2NP DSM WIP --- core/java/src/net/i2p/data/DatabaseEntry.java | 31 +++++++++++++++++++ core/java/src/net/i2p/data/LeaseSet.java | 25 --------------- .../i2p/data/i2np/DatabaseStoreMessage.java | 18 +++++++++++ 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/core/java/src/net/i2p/data/DatabaseEntry.java b/core/java/src/net/i2p/data/DatabaseEntry.java index f93cc65a2..19075daf7 100644 --- a/core/java/src/net/i2p/data/DatabaseEntry.java +++ b/core/java/src/net/i2p/data/DatabaseEntry.java @@ -62,6 +62,8 @@ public abstract class DatabaseEntry extends DataStructureImpl { // synch: this private Hash _currentRoutingKey; private long _routingKeyGenMod; + protected boolean _receivedAsPublished; + protected boolean _receivedAsReply; /** * A common interface to the timestamp of the two subclasses. @@ -253,4 +255,33 @@ public abstract class DatabaseEntry extends DataStructureImpl { return false; return DSAEngine.getInstance().verifySignature(_signature, data, spk); } + + /** + * If true, we received this LeaseSet by a remote peer publishing it to + * us, rather than by searching for it ourselves or locally creating it. + * Default false. + * + * @since 0.9.58 moved up from LeaseSet + */ + public boolean getReceivedAsPublished() { return _receivedAsPublished; } + + /** + * @since 0.9.58 moved up from LeaseSet + */ + public void setReceivedAsPublished(boolean received) { _receivedAsPublished = received; } + + /** + * If true, we received this LeaseSet by searching for it + * Default false. + * + * @since 0.7.14, moved up from LeaseSet in 0.9.58 + */ + public boolean getReceivedAsReply() { return _receivedAsReply; } + + /** + * set to true + * + * @since 0.7.14, moved up from LeaseSet in 0.9.58 + */ + public void setReceivedAsReply() { _receivedAsReply = true; } } diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java index 2fe4aa558..96159b443 100644 --- a/core/java/src/net/i2p/data/LeaseSet.java +++ b/core/java/src/net/i2p/data/LeaseSet.java @@ -68,8 +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 _leases; - protected boolean _receivedAsPublished; - private boolean _receivedAsReply; private Hash _receivedBy; // Store these since isCurrent() and getEarliestLeaseDate() are called frequently private long _firstExpiration; @@ -186,29 +184,6 @@ public class LeaseSet extends DatabaseEntry { throw new IllegalArgumentException("Signing key type mismatch"); _signingKey = key; } - - /** - * If true, we received this LeaseSet by a remote peer publishing it to - * us, rather than by searching for it ourselves or locally creating it. - * Default false. - */ - public boolean getReceivedAsPublished() { return _receivedAsPublished; } - - /** Default false */ - public void setReceivedAsPublished(boolean received) { _receivedAsPublished = received; } - - /** - * If true, we received this LeaseSet by searching for it - * Default false. - * @since 0.7.14 - */ - public boolean getReceivedAsReply() { return _receivedAsReply; } - - /** - * set to true - * @since 0.7.14 - */ - public void setReceivedAsReply() { _receivedAsReply = true; } /** * The Hash of the local client that received this LS, diff --git a/router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java b/router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java index 54eab321d..07dda2cdd 100644 --- a/router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java +++ b/router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java @@ -41,6 +41,7 @@ public class DatabaseStoreMessage extends FastI2NPMessageImpl { private long _replyToken; private TunnelId _replyTunnel; private Hash _replyGateway; + private boolean _receivedAsReply; public DatabaseStoreMessage(I2PAppContext context) { super(context); @@ -101,6 +102,23 @@ public class DatabaseStoreMessage extends FastI2NPMessageImpl { public Hash getReplyGateway() { return _replyGateway; } public void setReplyGateway(Hash peer) { _replyGateway = peer; } + /** + * If true, we received this by searching for it. + * Note that searches may query multiple peers in parallel; + * only the first reply may have this set, and a reply + * received after the reply job times out will not have this set. + * Default false. + * + * @since 0.9.58 + */ + public boolean getReceivedAsReply() { return _receivedAsReply; } + + /** + * set to true + * @since 0.9.58 + */ + public void setReceivedAsReply() { _receivedAsReply = true; } + public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset;