effectivePriority

The effective priority / sort value of piece: a verbatim port of piece_pos::priority(piece_picker const*).

Returns -1 when the piece must not appear in the pick list: it is filtered (priority 0), we already have it, no peer has it, or it is in the full/finished download bucket (all blocks already requested/received).

Otherwise the value is availability * (PRIORITY_LEVELS - piecePriority) * PRIO_FACTOR + adjustment where availability = peerCount + 1 and the adjustment keeps actively downloading (partial) pieces a notch ahead of untouched ones:

  • -3 for a piece already in the downloading bucket,

  • -2 for an open (not-yet-downloading) piece.

A lower value is picked first, so low availability and high manual priority both pull the value down.