Raise an exception if the node's ID has changed. This means the node's
returned results will be ignored.
The KTable replaceStaleNode now adds the new node if there's space even
if the old one isn't found. This is due to the node ID having changed
resulting in instantly removing the node from the routing table.
The handler for the ping result in insertNode was mistakenly taking the
Failure returned as a result as a node and passing it to replaceStaleNode.
(datetime.now() - old.lastSeen) >
timedelta(seconds=self.config['MIN_PING_INTERVAL'])):
- def _staleNodeHandler(oldnode = old, newnode = node):
+ def _staleNodeHandler(failure, oldnode = old, newnode = node):
"""The pinged node never responded, so replace it."""
self.table.replaceStaleNode(oldnode, newnode)
if self.id != NULL_ID and senderid != self.id:
log.msg("Got response from different node than expected.")
self.table.invalidateNode(self)
+ raise Exception, "Node ID has changed"
return dict
try:
it = self.buckets[i].l.index(stale.num)
except ValueError:
- return
-
- # Remove the stale node and insert the new one
- del(self.buckets[i].l[it])
- if new:
+ pass
+ else:
+ # Remove the stale node
+ del(self.buckets[i].l[it])
+
+ # Insert the new node
+ if new and self._bucketIndexForInt(new.num) == i and len(self.buckets[i].l) < self.config['K']:
self.buckets[i].l.append(new)
def insertNode(self, node, contacted = True):