def send_bitfield(self):
"""
Tell the peer all the pieces you have in a really compact form.
"""
# the pieces are compacted in sequence in to bits
field = BitArray(
map(
lambda (sha, piece): sha == piece.digest,
self.torrent.pieces.items()
)
)
self.send_payload(5, field.tobytes())
评论列表
文章目录