Only touch a bucket if a find request targets it.
[quix0rs-apt-p2p.git] / apt_p2p_Khashmir / khashmir.py
index d3ee9ee847add5031a9067ce5b3fd1e123bb8c5f..968ddeb63a6914a68d50919fe7083fd52a31582a 100644 (file)
@@ -180,6 +180,9 @@ class KhashmirBase(protocol.Factory):
         @param callback: the method to call with the results, it must take 1
             parameter, the list of K closest nodes
         """
+        # Mark the bucket as having been accessed
+        self.table.touch(id)
+        
         # Start with our node
         nodes = [copy(self.node)]
 
@@ -405,6 +408,9 @@ class KhashmirRead(KhashmirBase):
         @param callback: the method to call with the results, it must take 1
             parameter, the list of nodes with values
         """
+        # Mark the bucket as having been accessed
+        self.table.touch(key)
+        
         # Start with ourself
         nodes = [copy(self.node)]