java.lang.Object
net.i2p.router.networkdb.kademlia.StaleContactTrimmer
- All Implemented Interfaces:
KBucketTrimmer<Hash>
Evicts the least-recently-attested peer from a full routing bucket so the netdb routing table rotates toward live peers instead of filling with dead-but-unexpired routers. Liveness is the newest of the peer profile's heard-about / heard-from / successful-send times. A peer with no profile counts as never seen. The oldest entry is only evicted when it is older than the grace window, otherwise the newcomer is rejected. Peers with an established session are never eviction candidates — same protection ExpireRoutersJob gives them.
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final longHow long an entry is protected from eviction even when stale.Constructor Summary
ConstructorsConstructorDescriptionStaleContactTrimmer(RouterContext context) Evict stale entries using this context's clock and peer profiles.Method Summary
Field Details
GRACE
static final long GRACEHow long an entry is protected from eviction even when stale.- See Also:
Constructor Details
StaleContactTrimmer
StaleContactTrimmer(RouterContext context) Evict stale entries using this context's clock and peer profiles.- Parameters:
context- the router context, for the clock and profile organizer
Method Details
trim
Description copied from interface:KBucketTrimmerCalled from add() just before adding the entry. You may call getEntries() and/or remove() from here. Do NOT call add(). To always discard a newer entry, always return false.- Specified by:
trimin interfaceKBucketTrimmer<Hash>- Parameters:
kbucket- the kbucket that is now too bigtoAdd- the entry the bucket is about to accept- Returns:
- true to actually add the entry.
lastSeen
The newest contact evidence for a peer, 0 when there is none. Static and package-visible so ExpireRoutersJob scores staleness the same way.- Parameters:
context- the router contextpeer- the peer hash- Returns:
- context time of the newest evidence, or 0