org.klomp.snark.dht

## Class Peer

- java.lang.Object
- - net.i2p.data.SimpleDataStructure
  - - net.i2p.data.Hash
    - - org.klomp.snark.dht.Peer

- All Implemented Interfaces:
    DataStructure

      class Peer
      extends Hash

  Represents a single peer participating in a specific torrent within the DHT tracker.

  This class extends Hash to store the peer's identification (typically their destination hash) along with metadata about their participation in the torrent. The DHT tracker maintains collections of these peers to respond to peer discovery requests from other clients.

  Each peer tracks when it was last seen and whether it's a seed (has the complete torrent). This information is used to prioritize peers in responses and to maintain an accurate view of the torrent's swarm health.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.data.Hash

      `FAKE_HASH, HASH_LENGTH`

    - ### Fields inherited from class net.i2p.data.SimpleDataStructure

      `_data`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Peer(byte[] data)` Creates a new peer with the specified identification data.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isSeed()` Returns whether this peer is a seed (has the complete torrent).
    `long` | `lastSeen()` Returns the timestamp when this peer was last seen active in the torrent.
    `void` | `setLastSeen(long now)` Updates the timestamp when this peer was last seen.
    `void` | `setSeed(boolean isSeed)` Sets whether this peer is a seed.

    - ### Methods inherited from class net.i2p.data.Hash

      `clearCache, create, create, create, hashCode, length, readBytes, setData, toBase32, toBase64`

    - ### Methods inherited from class net.i2p.data.SimpleDataStructure

      `calculateHash, equals, fromBase64, fromByteArray, getData, read, toByteArray, toString, writeBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Peer

          public Peer(byte[] data)

      Creates a new peer with the specified identification data.
      Parameters:
        `data` - the peer's identification data (typically destination hash)

  - ### Method Detail

    - #### isSeed

          public boolean isSeed()

      Returns whether this peer is a seed (has the complete torrent).

      Seeds are prioritized differently in peer responses as they can provide the complete torrent to leechers. This information is also used to calculate swarm health statistics.

      Returns:
        true if this peer has the complete torrent, false otherwise

    - #### lastSeen

          public long lastSeen()

      Returns the timestamp when this peer was last seen active in the torrent.
      Returns:
        the timestamp in milliseconds since epoch, or 0 if never seen

    - #### setLastSeen

          public void setLastSeen(long now)

      Updates the timestamp when this peer was last seen.
      Parameters:
        `now` - the current timestamp in milliseconds since epoch

    - #### setSeed

          public void setSeed(boolean isSeed)

      Sets whether this peer is a seed.
      Parameters:
        `isSeed` - true if this peer has the complete torrent, false otherwise