Exemplo n.º 1
0
 def _got_have_all(self, have=None):
     if self.multidownload.storage.get_amount_left() == 0:
         self.connector.close()
         return
     if have is None:
         # bleh
         n = self.multidownload.numpieces
         rlen, extra = divmod(n, 8)
         if extra:
             extra = chr((0xFF << (8 - extra)) & 0xFF)
         else:
             extra = ''
         s = (chr(0xFF) * rlen) + extra
         have = Bitfield(n, s)
     self.have = have
     self.multidownload.got_have_all()
     if self.multidownload.rm.endgame:
         for piece, begin, length in self.multidownload.all_requests:
             self.interested = True
             self.connector.send_interested()
             return
     for i in self.multidownload.rm.iter_want():
         self.interested = True
         self.connector.send_interested()
         return
Exemplo n.º 2
0
 def __init__(self, multidownload, connector):
     self.multidownload = multidownload
     self.connector = connector
     self.choked = True
     self.interested = False
     self.prefer_full = False
     self.active_requests = set()
     self.expecting_reject = set()
     self.intro_size = self.multidownload.chunksize * 4 # just a guess
     self.measure = Measure(multidownload.config['max_rate_period'])
     self.peermeasure = Measure(
         max(multidownload.storage.piece_size / 10000, 20))
     self.have = Bitfield(multidownload.numpieces)
     self.last = 0
     self.example_interest = None
     self.guard = BadDataGuard(self)
     self.suggested_pieces = []
     self.allowed_fast_pieces = []
     self._useful_received_listeners = set()
     self._raw_received_listeners = set()
     
     self.add_useful_received_listener(self.measure.update_rate)
     self.total_bytes = 0
     self.add_useful_received_listener(self.accumulate_total)
     
     self.payment_key_status ={} #hash with retries of sending payment key: key=(idx,offset,len) val ("statustring",retries)
                                 #todo move to multidownload, and later to seperate package
     self.peer_certificate = None
     self.own_certificate_is_sent_to_peer = False
Exemplo n.º 3
0
    def __init__(self, multidownload, connector):
        self.multidownload = multidownload
        self.connector = connector
        self.choked = True
        self.interested = False
        self.prefer_full = False
        self.active_requests = set()
        self.expecting_reject = set()
        self.intro_size = self.multidownload.chunksize * 4  # just a guess
        self.measure = Measure(multidownload.config['max_rate_period'])
        self.peermeasure = Measure(
            max(multidownload.storage.piece_size / 10000, 20))
        self.have = Bitfield(multidownload.numpieces)
        self.last = 0
        self.example_interest = None
        self.guard = BadDataGuard(self)
        self.suggested_pieces = []
        self.allowed_fast_pieces = []
        self._useful_received_listeners = set()
        self._raw_received_listeners = set()

        self.add_useful_received_listener(self.measure.update_rate)
        self.total_bytes = 0
        self.add_useful_received_listener(self.accumulate_total)