java.lang.Object
net.i2p.router.peermanager.PeerTestJob.PeerData
- Enclosing class:
PeerTestJob
Cached peer data to eliminate repeated lookups and string parsing.
This class consolidates all frequently accessed peer information into a single object, reducing database queries and improving performance during peer testing. All data is immutable once created, making it thread-safe for concurrent testing.
Performance Benefits:
- Single netDb lookup instead of multiple calls
- Pre-parsed capability flags (no repeated string operations)
- Cached short hash for logging (avoids repeated base64 encoding)
- Tier rank resolved once per candidate instead of per sort comparison
Field Summary
FieldsModifier and TypeFieldDescription(package private) final StringThe peer's bandwidth tier (O, P, X, K, L, M, N) or empty string.(package private) final StringRaw capabilities string fromRouterInfo(may be null).(package private) final booleanWhether the peer has the reachable capability flag.(package private) final PeerProfileThe peer's performance profile (null if no profile exists).(package private) final RouterInfoThe peer's RouterInfo from the network database (null if not found locally).(package private) final StringShortened hash identifier for logging (first 6 chars of base64).(package private) intPrecomputed tier priority, 0 (fast) to 2 (other).Constructor Summary
ConstructorsConstructorDescriptionPeerData(RouterContext ctx, Hash peerHash) Creates a new PeerData instance by looking up all necessary information.Method Summary
All MethodsModifier and TypeMethodDescription(package private) static intOrder candidates by tier, then by staleness of the persisted tunnel-test EWMA (never tested first).
Field Details
tierRank
int tierRankPrecomputed tier priority, 0 (fast) to 2 (other). Assigned before sorting; seePeerTestJob.tierRank(ProfileOrganizer, Hash).routerInfo
The peer's RouterInfo from the network database (null if not found locally).profile
The peer's performance profile (null if no profile exists).shortHash
Shortened hash identifier for logging (first 6 chars of base64).isReachable
final boolean isReachableWhether the peer has the reachable capability flag.bandwidthTier
The peer's bandwidth tier (O, P, X, K, L, M, N) or empty string.capabilities
Raw capabilities string fromRouterInfo(may be null).
Constructor Details
PeerData
PeerData(RouterContext ctx, Hash peerHash) Creates a new PeerData instance by looking up all necessary information.- Parameters:
ctx- the router context for accessing network database and profilespeerHash- the hash of the peer to gather data for
Method Details
compareByTierThenStaleness
Order candidates by tier, then by staleness of the persisted tunnel-test EWMA (never tested first).Reads only precomputed fields, so the sort performs no lock acquisition at all.
- Parameters:
a- the candidate on the left of the comparisonb- the candidate on the right of the comparison- Returns:
- negative if a sorts first