java.lang.Object
net.i2p.router.peermanager.PeerTestJob.PeerData
Enclosing class:
PeerTestJob

private static class PeerTestJob.PeerDataextends Object
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 Details

    • tierRank

      int tierRank
      Precomputed tier priority, 0 (fast) to 2 (other). Assigned before sorting; see PeerTestJob.tierRank(ProfileOrganizer, Hash).
    • routerInfo

      final RouterInfo routerInfo
      The peer's RouterInfo from the network database (null if not found locally).
    • profile

      final PeerProfile profile
      The peer's performance profile (null if no profile exists).
    • shortHash

      final String shortHash
      Shortened hash identifier for logging (first 6 chars of base64).
    • isReachable

      final boolean isReachable
      Whether the peer has the reachable capability flag.
    • bandwidthTier

      final String bandwidthTier
      The peer's bandwidth tier (O, P, X, K, L, M, N) or empty string.
    • capabilities

      final String capabilities
      Raw capabilities string from RouterInfo (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 profiles
      peerHash - the hash of the peer to gather data for
  • Method Details

    • compareByTierThenStaleness

      static int compareByTierThenStaleness(PeerTestJob.PeerData a, PeerTestJob.PeerData b)
      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 comparison
      b - the candidate on the right of the comparison
      Returns:
      negative if a sorts first