pieceHashV2

fun pieceHashV2(index: Int): Sha256Hash?

The v2 piece hash: the merkle root of piece index's 16 KiB block leaves. This is the verification target for a v2 download. It comes from the piece layers, except for a file that fits in a single piece, where the file's own merkle root is the piece hash.

Single-file: index directly into the file's piece-layer row (or the file root for a one-piece file).

Multi-file v2/hybrid: every file starts on a piece boundary (pad files enforce this), so the piece is mapped to its owning file via FileStorage.fileForPiece, then to the file-relative piece index (piece - file's first piece). Pad files have no content hash (return null); a file spanning a single piece uses its own pieces root.