forked from LBRYCommunity/lbry-sdk
Merge branch 'dht-bug-fixes'
This commit is contained in:
commit
6be63b0bcd
3 changed files with 15 additions and 7 deletions
|
@ -16,6 +16,9 @@ at anytime.
|
||||||
* Fixed slow startup for nodes with many lbry files
|
* Fixed slow startup for nodes with many lbry files
|
||||||
* Fixed setting the external ip on startup
|
* Fixed setting the external ip on startup
|
||||||
* Fixed session startup not blocking on joining the dht
|
* Fixed session startup not blocking on joining the dht
|
||||||
|
* Fixed a bug that prevented replacing dht contacts
|
||||||
|
* Fixed lbryid length validation
|
||||||
|
* Fixed an old print statement that polluted logs
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
*
|
*
|
||||||
|
|
|
@ -484,8 +484,9 @@ class Node(object):
|
||||||
raise TypeError, 'No port available'
|
raise TypeError, 'No port available'
|
||||||
|
|
||||||
if 'lbryid' in value:
|
if 'lbryid' in value:
|
||||||
if len(value['lbryid']) > constants.key_bits:
|
if len(value['lbryid']) != constants.key_bits / 8:
|
||||||
raise ValueError, 'Invalid lbryid'
|
raise ValueError('Invalid lbryid (%i bytes): %s' % (len(value['lbryid']),
|
||||||
|
value['lbryid'].encode('hex')))
|
||||||
else:
|
else:
|
||||||
compact_address = compact_ip + compact_port + value['lbryid']
|
compact_address = compact_ip + compact_port + value['lbryid']
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -11,7 +11,6 @@ from zope.interface import implements
|
||||||
import constants
|
import constants
|
||||||
import kbucket
|
import kbucket
|
||||||
from interface import IRoutingTable
|
from interface import IRoutingTable
|
||||||
from error import TimeoutError
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -83,11 +82,16 @@ class TreeRoutingTable(object):
|
||||||
|
|
||||||
@type failure: twisted.python.failure.Failure
|
@type failure: twisted.python.failure.Failure
|
||||||
"""
|
"""
|
||||||
failure.trap(TimeoutError)
|
# 'failure' is a Failure with an error message in the format:
|
||||||
log.warning('==replacing contact==')
|
# "Timeout connecting to <node id hex>"
|
||||||
# Remove the old contact...
|
error_message = failure.getErrorMessage()
|
||||||
deadContactID = failure.getErrorMessage()
|
deadContactID = error_message[22:].decode('hex')
|
||||||
|
|
||||||
|
if len(deadContactID) != constants.key_bits / 8:
|
||||||
|
raise ValueError("invalid contact id")
|
||||||
|
log.debug("Replacing dead contact: %s", deadContactID.encode('hex'))
|
||||||
try:
|
try:
|
||||||
|
# Remove the old contact...
|
||||||
self._buckets[bucketIndex].removeContact(deadContactID)
|
self._buckets[bucketIndex].removeContact(deadContactID)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# The contact has already been removed (probably due to a timeout)
|
# The contact has already been removed (probably due to a timeout)
|
||||||
|
|
Loading…
Reference in a new issue