""",
(disk_id, block_ranges)
)
- infos = [_TorrentInfo.build(id_, info) for (id_, info) in cursor]
+ infos = [
+ _TorrentInfo.build(bytes(id_), bencode.decode(bytes(info)))
+ for (id_, info) in cursor
+ ]
for i in infos:
assert i.piece_length % BLOCK_SIZE == 0, f"entity {i.id.hex()} has invalid piece length"
if any(crypt_key is not None for (*_, crypt_key) in rows):
raise NotImplementedError("verify of encrypted data")
- for (piece_num, ranges) in itertools.groupby(rows, lambda t: t[0]):
+ for (piece_num, piece_rows) in itertools.groupby(rows, lambda t: t[0]):
+ block_ranges = [range(r.lower, r.upper) for (r, _) in piece_rows]
run = _V1Run(
entity_id = info.id,
entity_length = info.length,
piece_length = info.piece_length,
piece_num = piece_num,
- block_ranges = [range(r.lower, r.upper) for r in ranges],
+ block_ranges = block_ranges,
hash = info.hashes[piece_num],
)
return [
_V2Run(
- entity_id = entity_id,
+ entity_id = bytes(entity_id),
entity_length = entity_length,
piece_num = piece_num,
block_ranges = [range(block, block + 1)],
- hash = hash_,
+ hash = bytes(hash_),
)
- for (entity_id, entity_length, piece_num, block, entity_length, hash_, crypt_key) in rows
+ for (entity_id, entity_length, piece_num, block, entity_length, hash_, _) in rows
]