mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-24 11:12:18 +00:00
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:
parent
111cdc9e05
commit
673979c29a
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user