BlockInfo

class BlockInfo

Bookkeeping for one block of a downloading piece, the port of piece_picker::block_info. Only pieces that are partially downloaded keep an array of these (see DownloadingPiece); pieces we fully have or have never touched carry none.

In C++ this is a packed bit-field struct (14-bit numPeers + 2-bit state) to fit 8 bytes; we don't need the packing in Kotlin, so the fields are plain.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

How many peers currently have this block in their request queue. A block in BlockState.REQUESTED has numPeers > 0; in any other state it is 0. (End-game mode is the reason this can exceed 1.)

Link copied to clipboard
var peer: Any?

The opaque peer token this block was last requested from / downloaded from, or null. libtorrent stores a torrent_peer*; KiteTorrent keeps peers opaque, so the picker stores whatever token the caller passed in.

Link copied to clipboard

The state of this block.

Functions

Link copied to clipboard
fun reset()

Reset to the pristine "never touched" state, reused when a piece is recycled.