TorrentState

State the owning torrent passes into PeerList operations. This is the port of struct torrent_state (include/libtorrent/peer_list.hpp).

libtorrent deliberately routes the small amount of torrent/session context the peer list needs through this struct rather than giving the peer list a pointer to the torrent, so the data structure stays decoupled and unit-testable. We keep that design exactly: every mutating PeerList call that needs to know "are we finished", "how big may the list grow", "what's our external IP" takes a TorrentState.

A couple of fields are outputs written back by the peer list:

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Whether multiple connections to the same IP (different ports) are allowed.

Link copied to clipboard

Output: every TorrentPeer removed from the list during the call. The caller should clear references to these and then clearErased.

Link copied to clipboard

Output: set by PeerList.addPeer. True iff the peer was newly added.

Link copied to clipboard

Our external IP, for BEP 40 peer ranking.

Link copied to clipboard

True if the torrent has finished downloading (affects seed handling).

Link copied to clipboard

Diagnostic counter: how many peer-list slots were scanned this call.

Link copied to clipboard

Failcount at or above which a peer is no longer a connect candidate.

Link copied to clipboard

Maximum number of peers to keep in the list before weeding. 0 = unlimited.

Link copied to clipboard

Minimum seconds between reconnect attempts to the same peer.

Link copied to clipboard
var port: Int

The port to pair with our external IP when ranking (our listen port).

Functions

Link copied to clipboard

Clear the erased output list before reusing this state.