This commit is contained in:
Alex Grintsvayg 2017-04-25 14:21:13 -04:00
parent a50cbdcbb8
commit fd51d8ddf0
4 changed files with 9 additions and 10 deletions

View file

@ -99,7 +99,6 @@ disable=
redefined-variable-type, redefined-variable-type,
relative-import, relative-import,
signature-differs, signature-differs,
singleton-comparison,
super-init-not-called, super-init-not-called,
too-few-public-methods, too-few-public-methods,
too-many-arguments, too-many-arguments,

View file

@ -83,7 +83,7 @@ class Bencode(Encoding):
elif type(data) == float: elif type(data) == float:
# This (float data type) is a non-standard extension to the original Bencode algorithm # This (float data type) is a non-standard extension to the original Bencode algorithm
return 'f%fe' % data return 'f%fe' % data
elif data == None: elif data is None:
# This (None/NULL data type) is a non-standard extension # This (None/NULL data type) is a non-standard extension
# to the original Bencode algorithm # to the original Bencode algorithm
return 'n' return 'n'

View file

@ -22,7 +22,7 @@ class RequestMessage(Message):
""" Message containing an RPC request """ """ Message containing an RPC request """
def __init__(self, nodeID, method, methodArgs, rpcID=None): def __init__(self, nodeID, method, methodArgs, rpcID=None):
if rpcID == None: if rpcID is None:
rpcID = generate_id() rpcID = generate_id()
Message.__init__(self, rpcID, nodeID) Message.__init__(self, rpcID, nodeID)
self.request = method self.request = method

View file

@ -93,13 +93,13 @@ class Node(object):
self.next_refresh_call = None self.next_refresh_call = None
self.next_change_token_call = None self.next_change_token_call = None
# Create k-buckets (for storing contacts) # Create k-buckets (for storing contacts)
if routingTableClass == None: if routingTableClass is None:
self._routingTable = routingtable.OptimizedTreeRoutingTable(self.id) self._routingTable = routingtable.OptimizedTreeRoutingTable(self.id)
else: else:
self._routingTable = routingTableClass(self.id) self._routingTable = routingTableClass(self.id)
# Initialize this node's network access mechanisms # Initialize this node's network access mechanisms
if networkProtocol == None: if networkProtocol is None:
self._protocol = protocol.KademliaProtocol(self) self._protocol = protocol.KademliaProtocol(self)
else: else:
self._protocol = networkProtocol self._protocol = networkProtocol
@ -107,7 +107,7 @@ class Node(object):
self.token_secret = self._generateID() self.token_secret = self._generateID()
self.old_token_secret = None self.old_token_secret = None
self.change_token() self.change_token()
if dataStore == None: if dataStore is None:
self._dataStore = datastore.DictDataStore() self._dataStore = datastore.DictDataStore()
else: else:
self._dataStore = dataStore self._dataStore = dataStore
@ -454,7 +454,7 @@ class Node(object):
to fix this (perhaps use a stream from the Protocol class?) to fix this (perhaps use a stream from the Protocol class?)
""" """
# Get the sender's ID (if any) # Get the sender's ID (if any)
if originalPublisherID == None: if originalPublisherID is None:
if '_rpcNodeID' in kwargs: if '_rpcNodeID' in kwargs:
originalPublisherID = kwargs['_rpcNodeID'] originalPublisherID = kwargs['_rpcNodeID']
else: else:
@ -471,7 +471,7 @@ class Node(object):
# raise TypeError, 'No contact info available' # raise TypeError, 'No contact info available'
if ((self_store is False) and if ((self_store is False) and
(not 'token' in value or not self.verify_token(value['token'], compact_ip))): ('token' not in value or not self.verify_token(value['token'], compact_ip))):
raise ValueError('Invalid or missing token') raise ValueError('Invalid or missing token')
if 'port' in value: if 'port' in value:
@ -584,7 +584,7 @@ class Node(object):
""" """
findValue = rpc != 'findNode' findValue = rpc != 'findNode'
if startupShortlist == None: if startupShortlist is None:
shortlist = self._routingTable.findCloseNodes(key, constants.alpha) shortlist = self._routingTable.findCloseNodes(key, constants.alpha)
if key != self.id: if key != self.id:
# Update the "last accessed" timestamp for the appropriate k-bucket # Update the "last accessed" timestamp for the appropriate k-bucket
@ -776,7 +776,7 @@ class _IterativeFindHelper(object):
if self.key in self.find_value_result: if self.key in self.find_value_result:
self.outer_d.callback(self.find_value_result) self.outer_d.callback(self.find_value_result)
return return
elif len(self.active_contacts) and self.find_value == False: elif len(self.active_contacts) and self.find_value is False:
if self._is_all_done(): if self._is_all_done():
# TODO: Re-send the FIND_NODEs to all of the k closest nodes not already queried # TODO: Re-send the FIND_NODEs to all of the k closest nodes not already queried
# #