Merge branch 'i2p.i2p.2.4.0-move-receivedby-logic-to-dbe' into 'master'

Router: move getReceivedBy and getReceivedAsPublished into DatabaseEntry

Closes #430

See merge request i2p-hackers/i2p.i2p!132
This commit is contained in:
idk
2023-10-30 00:24:23 +00:00
4 changed files with 25 additions and 28 deletions

View File

@@ -62,8 +62,27 @@ public abstract class DatabaseEntry extends DataStructureImpl {
// synch: this // synch: this
private Hash _currentRoutingKey; private Hash _currentRoutingKey;
private long _routingKeyGenMod; private long _routingKeyGenMod;
protected boolean _receivedAsPublished; private boolean _receivedAsPublished;
protected boolean _receivedAsReply; 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. * A common interface to the timestamp of the two subclasses.

View File

@@ -68,7 +68,6 @@ public class LeaseSet extends DatabaseEntry {
protected SigningPublicKey _signingKey; protected SigningPublicKey _signingKey;
// Keep leases in the order received, or else signature verification will fail! // Keep leases in the order received, or else signature verification will fail!
protected final List<Lease> _leases; protected final List<Lease> _leases;
private Hash _receivedBy;
// Store these since isCurrent() and getEarliestLeaseDate() are called frequently // Store these since isCurrent() and getEarliestLeaseDate() are called frequently
private long _firstExpiration; private long _firstExpiration;
protected long _lastExpiration; protected long _lastExpiration;
@@ -185,22 +184,14 @@ public class LeaseSet extends DatabaseEntry {
_signingKey = key; _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 * Also sets receivedAsReply to true
* @param localClient may be null * @param localClient may be null
* @since 0.9.47 * @since 0.9.47
*/ */
public void setReceivedBy(Hash localClient) { public void setReceivedBy(Hash localClient) {
_receivedAsReply = true; super.setReceivedBy(localClient);
_receivedBy = localClient; super.setReceivedAsReply();
} }
/** /**
@@ -331,7 +322,7 @@ public class LeaseSet extends DatabaseEntry {
} }
byte rv[] = out.toByteArray(); byte rv[] = out.toByteArray();
// if we are floodfill and this was published to us // if we are floodfill and this was published to us
if (_receivedAsPublished) if (getReceivedAsPublished())
_byteified = rv; _byteified = rv;
return rv; return rv;
} }

View File

@@ -396,7 +396,7 @@ public class LeaseSet2 extends LeaseSet {
} }
byte rv[] = out.toByteArray(); byte rv[] = out.toByteArray();
// if we are floodfill and this was published to us // if we are floodfill and this was published to us
if (_receivedAsPublished) if (getReceivedAsPublished())
_byteified = rv; _byteified = rv;
return rv; return rv;
} }

View File

@@ -86,19 +86,6 @@ public class RouterInfo extends DatabaseEntry {
public static final String PROP_CAPABILITIES = "caps"; public static final String PROP_CAPABILITIES = "caps";
public static final char CAPABILITY_HIDDEN = 'H'; public static final char CAPABILITY_HIDDEN = 'H';
private static final int MAX_ADDRESSES = 16; 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 /** Public string of chars which serve as bandwidth capacity markers
* NOTE: individual chars defined in Router.java * NOTE: individual chars defined in Router.java