Skip to content

Commit

Permalink
Merge branch 'i2p.i2p.2.4.0-move-receivedby-logic-to-dbe' into 'master'
Browse files Browse the repository at this point in the history
Router: move getReceivedBy and getReceivedAsPublished into DatabaseEntry

Closes #430

See merge request i2p-hackers/i2p.i2p!132
  • Loading branch information
eyedeekay committed Oct 30, 2023
2 parents 5450573 + fb8bb64 commit a320b25
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
23 changes: 21 additions & 2 deletions core/java/src/net/i2p/data/DatabaseEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 3 additions & 12 deletions core/java/src/net/i2p/data/LeaseSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -185,22 +184,14 @@ public void setSigningKey(SigningPublicKey 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
* @param localClient may be null
* @since 0.9.47
*/
public void setReceivedBy(Hash localClient) {
_receivedAsReply = true;
_receivedBy = localClient;
super.setReceivedBy(localClient);
super.setReceivedAsReply();
}

/**
Expand Down Expand Up @@ -331,7 +322,7 @@ protected byte[] getBytes() {
}
byte rv[] = out.toByteArray();
// if we are floodfill and this was published to us
if (_receivedAsPublished)
if (getReceivedAsPublished())
_byteified = rv;
return rv;
}
Expand Down
2 changes: 1 addition & 1 deletion core/java/src/net/i2p/data/LeaseSet2.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected byte[] getBytes() {
}
byte rv[] = out.toByteArray();
// if we are floodfill and this was published to us
if (_receivedAsPublished)
if (getReceivedAsPublished())
_byteified = rv;
return rv;
}
Expand Down
13 changes: 0 additions & 13 deletions router/java/src/net/i2p/data/router/RouterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a320b25

Please sign in to comment.