org.klomp.snark.dht

## Class Peers

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.concurrent.ConcurrentHashMap<Hash,Peer>
    - - org.klomp.snark.dht.Peers

- All Implemented Interfaces:
    Serializable, ConcurrentMap<Hash,Peer>, Map<Hash,Peer>

      class Peers
      extends ConcurrentHashMap<Hash,Peer>

  Thread-safe collection of all peers participating in a single torrent.

  This class extends ConcurrentHashMap to provide a thread-safe mapping from peer identification (Hash) to Peer objects. It represents the complete set of known peers for a specific torrent that the DHT tracker is aware of.

  The collection is used by the DHT tracker to respond to get_peer requests, providing peers that are actively participating in the torrent. The concurrent implementation ensures thread safety when multiple DHT operations are accessing or modifying the peer list simultaneously.

  Each peer in the collection includes metadata such as last seen time and seed status, which can be used to prioritize responses and maintain accurate swarm statistics.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap

      `ConcurrentHashMap.KeySetView<K,V>`

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Peers()` Creates a new peer collection with initial capacity for 8 peers.

  - ### Method Summary

    - ### Methods inherited from class java.util.concurrent.ConcurrentHashMap

      `clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values`

    - ### Methods inherited from class java.util.AbstractMap

      `clone`

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

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

- - ### Constructor Detail

    - #### Peers

          public Peers()

      Creates a new peer collection with initial capacity for 8 peers.

      The initial capacity is set to 8 as a reasonable default for most torrents, balancing memory usage with the need to avoid frequent resizing for small to medium-sized swarms.