#2382 closed enhancement (fixed)
Fix isUnreachable() and wasUnreachable() in TransportImpl.java
Reported by: | jogger | Owned by: | zzz |
---|---|---|---|
Priority: | minor | Milestone: | 0.9.39 |
Component: | router/transport | Version: | 0.9.37 |
Keywords: | Cc: | ||
Parent Tickets: | #2355 | Sensitive: | no |
Description (last modified by )
The following code takes the now() out of the critical path. Part of the solution for 2355.
public boolean isUnreachable(Hash peer) { // long now = _context.clock().now(); synchronized (_unreachableEntries) { Long when = _unreachableEntries.get(peer); if (when == null) return false; // if (when.longValue() + UNREACHABLE_PERIOD < now) { if (when.longValue() + UNREACHABLE_PERIOD < _context.clock().now()) { _unreachableEntries.remove(peer); return false; } else { return true; } } } public boolean wasUnreachable(Hash peer) { // long now = _context.clock().now(); synchronized (_wasUnreachableEntries) { Long when = _wasUnreachableEntries.get(peer); if (when != null) { // if (when.longValue() + WAS_UNREACHABLE_PERIOD < now) { if (when.longValue() + WAS_UNREACHABLE_PERIOD < _context.clock().now()) { _unreachableEntries.remove(peer); return false; } else { return true; } } } RouterInfo ri = _context.netDb().lookupRouterInfoLocally(peer); if (ri == null) return false; return null == ri.getTargetAddress(this.getStyle()); }
Subtickets
Change History (6)
comment:1 Changed 2 years ago by
comment:2 Changed 2 years ago by
never worked with diff.
now() may not be needed at all. So one can ditch the now variable and move _context.clock().now() right to the point.
The "else" is also unnecessary.
comment:3 Changed 2 years ago by
you asked us over on zzz.i2p how you could contribute more; providing diffs would be a big help.
assuming you're on linux or similar:
cp Foo.java Foo.java.orig
(make your changes to Foo.java)
diff -u Foo.java.orig Foo.java > foo.diff
(attach foo.diff here, or copy it between three open curly braces and three close curly braces)
comment:4 Changed 2 years ago by
Description: | modified (diff) |
---|
comment:5 Changed 2 years ago by
Milestone: | undecided → 0.9.39 |
---|---|
Priority: | major → minor |
Resolution: | → fixed |
Status: | new → closed |
In 0d44c0843ca63d3d78061f6cbf923fac72b2abc8 to be 0.9.38-7
comment:6 Changed 2 years ago by
Parent Tickets: | → 2355 |
---|
I get the idea but it's a bit difficult to read. Can you format it as a diff?