class Peer extends Hash
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.
FAKE_HASH, HASH_LENGTH_data| Constructor and Description |
|---|
Peer(byte[] data)
Creates a new peer with the specified identification data.
|
| 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.
|
clearCache, create, create, create, hashCode, length, readBytes, setData, toBase32, toBase64calculateHash, equals, fromBase64, fromByteArray, getData, read, toByteArray, toString, writeBytespublic Peer(byte[] data)
data - the peer's identification data (typically destination hash)public boolean isSeed()
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.
public long lastSeen()
public void setLastSeen(long now)
now - the current timestamp in milliseconds since epochpublic void setSeed(boolean isSeed)
isSeed - true if this peer has the complete torrent, false otherwise