set the peer search timeout as configured and raise it to 30s

This commit is contained in:
Victor Shyba 2018-07-03 13:35:34 -03:00
parent 7e0784d8e0
commit 1cc7ce69ab
2 changed files with 5 additions and 2 deletions

View file

@ -291,7 +291,7 @@ ADJUSTABLE_SETTINGS = {
'run_reflector_server': (bool, False),
'sd_download_timeout': (int, 3),
'share_usage_data': (bool, True), # whether to share usage stats and diagnostic info with LBRY
'peer_search_timeout': (int, 3),
'peer_search_timeout': (int, 30),
'use_auth_http': (bool, False),
'use_upnp': (bool, True),
'use_keyring': (bool, False),

View file

@ -4,6 +4,7 @@ import logging
from zope.interface import implements
from twisted.internet import defer
from lbrynet.interfaces import IPeerFinder
from lbrynet import conf
log = logging.getLogger(__name__)
@ -43,12 +44,14 @@ class DHTPeerFinder(DummyPeerFinder):
"""
bin_hash = binascii.unhexlify(blob_hash)
finished_deferred = self.dht_node.iterativeFindValue(bin_hash)
timeout = timeout or conf.settings['peer_search_timeout']
if timeout:
finished_deferred.addTimeout(timeout, self.dht_node.clock)
try:
peer_list = yield finished_deferred
except defer.TimeoutError:
log.warning("DHT timed out while looking peers for blob {}".format(blob_hash))
log.warning("DHT timed out while looking peers for blob"
" %s after %s seconds.", blob_hash, timeout)
peer_list = []
peers = set(peer_list)