Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/kademlia/routing/Contact.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kademlia.routing;

import kademlia.node.KademliaId;
import kademlia.node.Node;

/**
Expand Down Expand Up @@ -106,6 +107,17 @@ public int compareTo(Contact o)
return 0;
}

if (this.lastSeen() == o.lastSeen()) {

for (int i = 0; i < KademliaId.ID_LENGTH / 8; i++) {
int compare = Byte.compare(this.getNode().getNodeId().getBytes()[i], o.getNode().getNodeId().getBytes()[i]);
if (compare != 0) {
return compare;
}
}

}

return (this.lastSeen() > o.lastSeen()) ? 1 : -1;
}

Expand Down