Routing Table

- We were not resetting the stale count of a contact when we saw it again, did that now
This commit is contained in:
Joshua Kissoon 2014-05-10 19:52:21 +05:30
parent 111cdc9e05
commit 673979c29a
2 changed files with 10 additions and 0 deletions

View File

@ -90,6 +90,14 @@ public class Contact implements Comparable<Contact>
return this.staleCount; return this.staleCount;
} }
/**
* Reset the stale count of the contact if it's recently seen
*/
public void resetStaleCount()
{
this.staleCount = 0;
}
@Override @Override
public int compareTo(Contact o) public int compareTo(Contact o)
{ {

View File

@ -54,6 +54,7 @@ public class KadBucketImpl implements KadBucket
*/ */
Contact tmp = this.removeFromContacts(c.getNode()); Contact tmp = this.removeFromContacts(c.getNode());
tmp.setSeenNow(); tmp.setSeenNow();
tmp.resetStaleCount();
this.contacts.add(tmp); this.contacts.add(tmp);
} }
else else
@ -125,6 +126,7 @@ public class KadBucketImpl implements KadBucket
return false; return false;
} }
/* Contact exist, lets remove it only if our replacement cache has a replacement */
if (!this.replacementCache.isEmpty()) if (!this.replacementCache.isEmpty())
{ {
/* Replace the contact with one from the replacement cache */ /* Replace the contact with one from the replacement cache */