From 1e6b9f2e3835d4f7dbd3c588cd186a4a4a3c4a65 Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Thu, 1 May 2014 11:44:25 +0530 Subject: [PATCH] Replacement Cache update - If we're trying to add a node that's already in the replacement cache, update the last seen time of this node --- src/kademlia/routing/KadBucket.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kademlia/routing/KadBucket.java b/src/kademlia/routing/KadBucket.java index a9b0f09..3b45b00 100644 --- a/src/kademlia/routing/KadBucket.java +++ b/src/kademlia/routing/KadBucket.java @@ -173,7 +173,13 @@ public class KadBucket implements Bucket /* Just return if this contact is already in our replacement cache */ if (this.replacementCache.containsKey(c)) { - /* @todo update last seen time */ + /** + * If the contact is already in the bucket, lets update that we've seen it + * We need to remove and re-add the contact to get the Sorted Set to update sort order + */ + Contact tmp = this.replacementCache.remove(c); + tmp.setSeenNow(); + this.replacementCache.put(tmp, tmp); return; }