we just have one supplier not a list of suppliers
This commit is contained in:
parent
60c7261871
commit
75b977dff9
1 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ class DHTHashAnnouncer(object):
|
||||||
def __init__(self, dht_node, peer_port):
|
def __init__(self, dht_node, peer_port):
|
||||||
self.dht_node = dht_node
|
self.dht_node = dht_node
|
||||||
self.peer_port = peer_port
|
self.peer_port = peer_port
|
||||||
self.suppliers = []
|
self.supplier = None
|
||||||
self.next_manage_call = None
|
self.next_manage_call = None
|
||||||
self.hash_queue = collections.deque()
|
self.hash_queue = collections.deque()
|
||||||
self._concurrent_announcers = 0
|
self._concurrent_announcers = 0
|
||||||
|
@ -62,7 +62,7 @@ class DHTHashAnnouncer(object):
|
||||||
self._manage_call_lc.stop()
|
self._manage_call_lc.stop()
|
||||||
|
|
||||||
def add_supplier(self, supplier):
|
def add_supplier(self, supplier):
|
||||||
self.suppliers.append(supplier)
|
self.supplier = supplier
|
||||||
|
|
||||||
def immediate_announce(self, blob_hashes):
|
def immediate_announce(self, blob_hashes):
|
||||||
if self.peer_port is not None:
|
if self.peer_port is not None:
|
||||||
|
@ -76,8 +76,8 @@ class DHTHashAnnouncer(object):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _announce_available_hashes(self):
|
def _announce_available_hashes(self):
|
||||||
log.debug('Announcing available hashes')
|
log.debug('Announcing available hashes')
|
||||||
for supplier in self.suppliers:
|
if self.supplier:
|
||||||
hashes = yield supplier.hashes_to_announce()
|
hashes = yield self.supplier.hashes_to_announce()
|
||||||
yield self._announce_hashes(hashes)
|
yield self._announce_hashes(hashes)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -155,10 +155,10 @@ class DHTHashAnnouncer(object):
|
||||||
stored_to = {}
|
stored_to = {}
|
||||||
for _, announced_to in announcer_results:
|
for _, announced_to in announcer_results:
|
||||||
stored_to.update(announced_to)
|
stored_to.update(announced_to)
|
||||||
|
|
||||||
log.info('Took %s seconds to announce %s hashes', time.time() - start, len(hashes))
|
log.info('Took %s seconds to announce %s hashes', time.time() - start, len(hashes))
|
||||||
seconds_per_blob = (time.time() - start) / len(hashes)
|
seconds_per_blob = (time.time() - start) / len(hashes)
|
||||||
for supplier in self.suppliers:
|
self.supplier.set_single_hash_announce_duration(seconds_per_blob)
|
||||||
supplier.set_single_hash_announce_duration(seconds_per_blob)
|
|
||||||
defer.returnValue(stored_to)
|
defer.returnValue(stored_to)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue