Documentation
¶
Overview ¶
Package fast implements the Allowed Fast Set generation algorithm from BEP 6 (Fast Extension).
http://www.bittorrent.org/beps/bep_0006.html
The algorithm is a deterministic function of the peer's IPv4 (masked to /24) and the torrent's info hash, producing a small set of piece indices the local peer is willing to serve while the remote peer is choked. The remote peer can independently compute the same set to verify the sender is honest.
Index ¶
Constants ¶
const DefaultK = 10
DefaultK is the number of allowed-fast pieces normally announced per peer. BEP 6 leaves the exact value implementation-defined; common clients use a small constant (mainline / libtorrent use 10).
Variables ¶
This section is empty.
Functions ¶
func GenerateFastSet ¶
GenerateFastSet returns up to k piece indices that the local peer will allow the remote peer to request even while choked.
k is the requested set size, numPieces is the total number of pieces in the torrent, infoHash is the torrent's 20-byte info hash, and ip is the remote peer's address (IPv4 only — IPv6 returns nil per BEP 6).
The algorithm follows BEP 6's reference pseudocode exactly so the remote peer can independently re-derive and verify the set.
Types ¶
This section is empty.