def __init__(self, torrent, savedir):
self.torrent = torrent
self.total_pieces = len(self.torrent.info.pieces)
self.peers = {}
# TODO: Come up with different data structure to store
# states of different pieces and blocks. Probably dict or set?
self.pending_blocks = []
self.ongoing_pieces = []
self.have_pieces = []
self.missing_pieces = self.make_pieces()
self.max_pending_time = 300 * 1000 # Seconds
self.progress_bar = Bar('Downloading', max=self.total_pieces)
if savedir == '.':
name = self.torrent.name
else:
name = os.path.join(savedir, self.torrent.name)
self.fd = os.open(name, os.O_RDWR | os.O_CREAT)
评论列表
文章目录