update peer_list
This commit is contained in:
parent
4f72098cad
commit
cc32d987b2
1 changed files with 9 additions and 11 deletions
|
@ -2903,24 +2903,22 @@ class Daemon(AuthJSONRPCServer):
|
||||||
if not utils.is_valid_blobhash(blob_hash):
|
if not utils.is_valid_blobhash(blob_hash):
|
||||||
raise Exception("invalid blob hash")
|
raise Exception("invalid blob hash")
|
||||||
|
|
||||||
finished_deferred = self.session.dht_node.getPeersForBlob(binascii.unhexlify(blob_hash), True)
|
finished_deferred = self.session.dht_node.iterativeFindValue(binascii.unhexlify(blob_hash))
|
||||||
|
|
||||||
def _trigger_timeout():
|
def trap_timeout(err):
|
||||||
if not finished_deferred.called:
|
err.trap(defer.TimeoutError)
|
||||||
log.debug("Peer search for %s timed out", blob_hash)
|
return []
|
||||||
finished_deferred.cancel()
|
|
||||||
|
|
||||||
timeout = timeout or conf.settings['peer_search_timeout']
|
|
||||||
self.session.dht_node.reactor_callLater(timeout, _trigger_timeout)
|
|
||||||
|
|
||||||
|
finished_deferred.addTimeout(timeout or conf.settings['peer_search_timeout'], self.session.dht_node.clock)
|
||||||
|
finished_deferred.addErrback(trap_timeout)
|
||||||
peers = yield finished_deferred
|
peers = yield finished_deferred
|
||||||
results = [
|
results = [
|
||||||
{
|
{
|
||||||
|
"node_id": node_id.encode('hex'),
|
||||||
"host": host,
|
"host": host,
|
||||||
"port": port,
|
"port": port
|
||||||
"node_id": node_id
|
|
||||||
}
|
}
|
||||||
for host, port, node_id in peers
|
for node_id, host, port in peers
|
||||||
]
|
]
|
||||||
defer.returnValue(results)
|
defer.returnValue(results)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue