NetDB: Use published date, not earliest lease expiration, for LS2 comparisons

Fix earliest LS expiration adjustment when publishing for LS2,
so .38 routers won't reject as not newer
Don't start new store after verify fail if we've already done so
Increase flood candidates for LS2
Version checks for encrypted LS2
FVSJ cleanups
log tweaks, javadocs
This commit is contained in:
zzz
2019-02-23 17:03:04 +00:00
parent 5440a3402f
commit 9cd90b0530
14 changed files with 295 additions and 87 deletions

View File

@ -52,6 +52,17 @@ public class LeaseSet2 extends LeaseSet {
_checked = true;
}
/**
* Published timestamp, as received.
* Different than getDate(), which is the earliest lease expiration.
*
* @return in ms, with 1 second resolution
* @since 0.9.39
*/
public long getPublished() {
return _published;
}
public boolean isUnpublished() {
return (_flags & FLAG_UNPUBLISHED) != 0;
}
@ -384,8 +395,10 @@ public class LeaseSet2 extends LeaseSet {
protected void writeHeader(OutputStream out) throws DataFormatException, IOException {
_destination.writeBytes(out);
if (_published <= 0)
_published = Clock.getInstance().now();
if (_published <= 0) {
// we round it here, so comparisons during verifies aren't wrong
_published = ((Clock.getInstance().now() + 500) / 1000) * 1000;
}
long pub1k = _published / 1000;
DataHelper.writeLong(out, 4, pub1k);
// Divide separately to prevent rounding errors
@ -575,8 +588,9 @@ public class LeaseSet2 extends LeaseSet {
buf.append("\n\tPublished: ").append(new java.util.Date(_published));
buf.append("\n\tExpires: ").append(new java.util.Date(_expires));
buf.append("\n\tLeases: #").append(getLeaseCount());
for (int i = 0; i < getLeaseCount(); i++)
for (int i = 0; i < getLeaseCount(); i++) {
buf.append("\n\t\t").append(getLease(i));
}
buf.append("]");
return buf.toString();
}