- All Implemented Interfaces:
Serializable, ConcurrentMap<Hash,Peer>, Map<Hash, Peer>
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 ConcurrentHashMap
ConcurrentHashMap.KeySetView<K,V> Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longPinned for serialized-form compatibility.Constructor Summary
ConstructorsMethod Summary
Methods inherited from class 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, valuesMethods inherited from class AbstractMap
clone
Field Details
serialVersionUID
private static final long serialVersionUIDPinned for serialized-form compatibility.- See Also:
Constructor Details
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.