fast

package
v1.54.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

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

View Source
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

func GenerateFastSet(k int, numPieces uint32, infoHash [20]byte, ip net.IP) []uint32

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL