Merge branch 'stop_conditions_find_value'

This commit is contained in:
Jack Robison 2018-07-03 13:09:58 -04:00
commit a9971677f8
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
4 changed files with 10 additions and 1 deletions

View file

@ -23,6 +23,8 @@ at anytime.
* *
### Changed ### Changed
* default for `peer_search_timeout` raised from 3 to 30 and being logged on console
* change iterative find stop condition on find value to allow it to continue until a value is found (or it times out)
* include all of our own blobs in the local dht datastore (as if we had announced them to ourselves) * include all of our own blobs in the local dht datastore (as if we had announced them to ourselves)
* ignore dht `store` token validation errors for the first expiration-time after startup (fixes failed `store` requests after a restart) * ignore dht `store` token validation errors for the first expiration-time after startup (fixes failed `store` requests after a restart)

View file

@ -291,7 +291,7 @@ ADJUSTABLE_SETTINGS = {
'run_reflector_server': (bool, False), 'run_reflector_server': (bool, False),
'sd_download_timeout': (int, 3), 'sd_download_timeout': (int, 3),
'share_usage_data': (bool, True), # whether to share usage stats and diagnostic info with LBRY '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_auth_http': (bool, False),
'use_upnp': (bool, True), 'use_upnp': (bool, True),
'use_keyring': (bool, False), 'use_keyring': (bool, False),

View file

@ -134,6 +134,9 @@ class _IterativeFind(object):
defer.returnValue(contact.id) defer.returnValue(contact.id)
def should_stop(self): def should_stop(self):
if self.is_find_value_request:
# search stops when it finds a value, let it run
return False
if self.prev_closest_node and self.closest_node and self.distance.is_closer(self.prev_closest_node.id, if self.prev_closest_node and self.closest_node and self.distance.is_closer(self.prev_closest_node.id,
self.closest_node.id): self.closest_node.id):
# we're getting further away # we're getting further away

View file

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