From 742952098988651e561baa30dcde02aeede2eddf Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Fri, 7 Mar 2008 19:56:17 -0800 Subject: [PATCH] Fixed justSeenNode in KTable to update the bucket properly. It now moves the seen node to the end and marks the bucket as having been updated. --- TODO | 12 ------------ apt_p2p_Khashmir/ktable.py | 6 ++++++ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index f726992..2475df8 100644 --- a/TODO +++ b/TODO @@ -1,15 +1,3 @@ -Evaluate and fix some errors in the ktable khashmir module. - -The KTable implementation has some possible errors in it. insertNode -does not remove the original and use the new node when updating a node -already in the table, as claimed by the comments. justSeenNode doesn't -verify that the found node is the node that was being looked for, nor -does it move the node to the end of the list of nodes (since they are -supposed to be sorted by their lastSeen time) or update the bucket's -last touched time.nodeFailed also doesn't verify the found node is the -right node. - - Consider what happens when we are the closest node. In some of the actions it is unclear what happens when we are one of the diff --git a/apt_p2p_Khashmir/ktable.py b/apt_p2p_Khashmir/ktable.py index 3e60f5c..864dfe5 100644 --- a/apt_p2p_Khashmir/ktable.py +++ b/apt_p2p_Khashmir/ktable.py @@ -226,6 +226,12 @@ class KTable: n = self.buckets[i].l[it] tstamp = n.lastSeen n.updateLastSeen() + + # Move the node to the end and touch the bucket + del(self.buckets[i].l[it]) + self.buckets[i].l.append(n) + self.buckets[i].touch() + return tstamp def invalidateNode(self, n): -- 2.39.5