Fixed justSeenNode in KTable to update the bucket properly.
authorCameron Dale <camrdale@gmail.com>
Sat, 8 Mar 2008 03:56:17 +0000 (19:56 -0800)
committerCameron Dale <camrdale@gmail.com>
Sat, 8 Mar 2008 03:56:17 +0000 (19:56 -0800)
It now moves the seen node to the end and marks the bucket as
having been updated.

TODO
apt_p2p_Khashmir/ktable.py

diff --git a/TODO b/TODO
index f72699275cc161b09c62fafc871a041e2c1f75fe..2475df8644fe1cd71481d45354eba98b7e9da367 100644 (file)
--- 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
index 3e60f5c37d0156e6f51c0f9d3543e689012424f4..864dfe50feaadf1732f3319e46f48d68403efdd9 100644 (file)
@@ -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):