fix dht rpc id length
This commit is contained in:
parent
78417db553
commit
e2259fd8f7
3 changed files with 12 additions and 3 deletions
|
@ -59,3 +59,5 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
|||
|
||||
h = get_lbry_hash_obj()
|
||||
key_bits = h.digest_size * 8 # 384 bits
|
||||
|
||||
rpc_id_length = 20
|
||||
|
|
|
@ -8,12 +8,17 @@
|
|||
# may be created by processing this file with epydoc: http://epydoc.sf.net
|
||||
|
||||
from lbrynet.core.utils import generate_id
|
||||
import constants
|
||||
|
||||
|
||||
class Message(object):
|
||||
""" Base class for messages - all "unknown" messages use this class """
|
||||
|
||||
def __init__(self, rpcID, nodeID):
|
||||
if len(rpcID) != constants.rpc_id_length:
|
||||
raise ValueError("invalid rpc id: %i bytes (expected 20)" % len(rpcID))
|
||||
if len(nodeID) != constants.key_bits / 8:
|
||||
raise ValueError("invalid node id: %i bytes (expected 48)" % len(nodeID))
|
||||
self.id = rpcID
|
||||
self.nodeID = nodeID
|
||||
|
||||
|
@ -23,7 +28,7 @@ class RequestMessage(Message):
|
|||
|
||||
def __init__(self, nodeID, method, methodArgs, rpcID=None):
|
||||
if rpcID is None:
|
||||
rpcID = generate_id()
|
||||
rpcID = generate_id()[:constants.rpc_id_length]
|
||||
Message.__init__(self, rpcID, nodeID)
|
||||
self.request = method
|
||||
self.args = methodArgs
|
||||
|
|
|
@ -422,8 +422,10 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
|||
self._sentMessages[messageID] = (remoteContactID, df, timeoutCall, method, args)
|
||||
else:
|
||||
# No progress has been made
|
||||
del self._partialMessagesProgress[messageID]
|
||||
del self._partialMessages[messageID]
|
||||
if messageID in self._partialMessagesProgress:
|
||||
del self._partialMessagesProgress[messageID]
|
||||
if messageID in self._partialMessages:
|
||||
del self._partialMessages[messageID]
|
||||
df.errback(TimeoutError(remoteContactID))
|
||||
|
||||
def _hasProgressBeenMade(self, messageID):
|
||||
|
|
Loading…
Reference in a new issue