コード例 #1
0
ファイル: khashmir.py プロジェクト: galaxy001/libtorrent
    def refreshTable(self, force=0):
        """
            force=1 will refresh table regardless of last bucket access time
        """
        def callback(nodes):
            pass

        refresh = [bucket for bucket in self.table.buckets if force or (len(bucket.l) < K) or len(filter(lambda a: a.invalid, bucket.l)) or (time() - bucket.lastAccessed > const.BUCKET_STALENESS)]
        for bucket in refresh:
            id = newIDInRange(bucket.min, bucket.max)
            self.findNode(id, callback)
コード例 #2
0
ファイル: khashmir.py プロジェクト: lelou6666/khashmir
 def refreshTable(self, force=0):
     """
         force=1 will refresh table regardless of last bucket access time
     """
     def callback(nodes):
         pass
 
     for bucket in self.table.buckets:
         if force or (time.time() - bucket.lastAccessed >= const.BUCKET_STALENESS):
             id = newIDInRange(bucket.min, bucket.max)
             self.findNode(id, callback)
コード例 #3
0
ファイル: factory.py プロジェクト: Alwnikrotikz/lh-abc
 def refreshTable(self, force = False, callback=lambda a: None):
     """
     Refresh the table
     force=True will refresh table regardless of last bucket access time
     """
     if DEBUG:
         print("Debug: DHT - refreshTable")
     for bucket in self.table.buckets:
         if force or (clock() - bucket.lastAccessed >= BUCKET_STALENESS):
             id = newIDInRange(bucket.min, bucket.max)
             self.findNode(id, callback)
コード例 #4
0
    def refreshTable(self, force=0):
        """
            force=1 will refresh table regardless of last bucket access time
        """
        def callback(nodes):
            pass

        refresh = [bucket for bucket in self.table.buckets if force or (len(bucket.l) < K) or len(filter(lambda a: a.invalid, bucket.l)) or (time() - bucket.lastAccessed > const.BUCKET_STALENESS)]
        for bucket in refresh:
            id = newIDInRange(bucket.min, bucket.max)
            self.findNode(id, callback)
コード例 #5
0
    def refreshTable(self, force=0):
        """
            force=1 will refresh table regardless of last bucket access time
        """
        def callback(nodes):
            pass

        for bucket in self.table.buckets:
            if force or (time.time() - bucket.lastAccessed >=
                         const.BUCKET_STALENESS):
                id = newIDInRange(bucket.min, bucket.max)
                self.findNode(id, callback)
コード例 #6
0
ファイル: khashmir.py プロジェクト: norpol/apt-p2p
 def refreshTable(self, force = False):
     """Check all the buckets for those that need refreshing.
     
     @param force: refresh all buckets regardless of last bucket access time
         (optional, defaults to False)
     """
     def callback(nodes):
         pass
 
     for bucket in self.table.buckets:
         if force or (datetime.now() - bucket.lastAccessed > 
                      timedelta(seconds=self.config['BUCKET_STALENESS'])):
             # Choose a random ID in the bucket and try and find it
             id = newIDInRange(bucket.min, bucket.max)
             self.findNode(id, callback)