connectOnePeer

fun connectOnePeer(sessionTime: Int, state: TorrentState): TorrentPeer?

Return the single best peer to try to connect to next, or null if there is none. This is the port of peer_list::connect_one_peer. It maintains a cache of pre-ranked candidates: stale entries (no longer candidates) are dropped, the cache is refilled via findConnectCandidates when empty, and the front (best) peer is popped and returned. The returned peer is guaranteed to be a current connect candidate (not banned, not connected, connectable).

Parameters

sessionTime

current session time (seconds) for reconnect back-off.