MetadataTransfer
Reassembles the metadata (info) blob from incoming UtMetadata data pieces and verifies it against the expected info-hash. This is the codec-side counterpart of ut_metadata_plugin::received_metadata / metadata_request in ut_metadata.cpp.
Construct it once the total size is known (from the first data message's total_size, or from the peer's metadata_size handshake field), feed pieces with addPiece, then once isComplete call verify to check the assembled bytes against the torrent's info-hash. libtorrent does the equivalent check via torrent::set_metadata (which hashes and compares); the expensive-invariant block at the top of ut_metadata_plugin::metadata() shows the exact hashes used: hasher(info) == v1 and hasher256(info) == v2.
This helper is deliberately self-contained and does no networking; it just owns the buffer and the per-piece "have" bitfield.
Parameters
the full length of the metadata blob, in bytes (must be > 0).
Properties
Functions
Convenience: accept a parsed UtMetadata.Message. Only UtMetadata.Type.DATA messages contribute; anything else returns false.
The assembled metadata bytes. Only meaningful once isComplete; before then it still returns the (partially-filled) buffer so callers can hash-check incrementally if they wish.
The list of piece indices still missing. Use it to drive UtMetadata.encodeRequest.
Verify the assembled metadata against an expected v1 (SHA-1) info-hash, that is hasher(info).final() == info_hashes().v1. Returns false if not yet isComplete.
Verify the assembled metadata against an expected v2 (SHA-256) info-hash, that is hasher256(info).final() == info_hashes().v2. Returns false if not yet isComplete.