Made a few KadBucket methods private

Changed the comparison of KademliaId to use the hashcode
This commit is contained in:
Joshua Kissoon 2014-05-09 16:05:14 +05:30
parent e8f0e20a8f
commit 58696d627a
4 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ public class DefaultConfiguration implements KadConfiguration
private final static long RESPONSE_TIMEOUT = 1500;
private final static long OPERATION_TIMEOUT = 3000;
private final static int CONCURRENCY = 10;
private final static int K = 10;
private final static int K = 5;
private final static int RCSIZE = 3;
private final static int STALE = 1;
private final static String LOCAL_FOLDER = "kademlia";

View File

@ -95,7 +95,7 @@ public class KademliaId implements Streamable
if (o instanceof KademliaId)
{
KademliaId nid = (KademliaId) o;
return Arrays.equals(this.getBytes(), nid.getBytes());
return this.hashCode() == nid.hashCode();
}
return false;
}

View File

@ -111,11 +111,11 @@ public class Node implements Streamable
if (o instanceof Node)
{
Node n = (Node) o;
if (o == this)
if (n == this)
{
return true;
}
return this.getNodeId().equals(((Node) o).getNodeId());
return this.getNodeId().equals(n.getNodeId());
}
return false;
}

View File

@ -142,7 +142,7 @@ public class KadBucketImpl implements KadBucket
return true;
}
public synchronized Contact getFromContacts(Node n)
private synchronized Contact getFromContacts(Node n)
{
for (Contact c : this.contacts)
{
@ -156,7 +156,7 @@ public class KadBucketImpl implements KadBucket
throw new NoSuchElementException("The contact does not exist in the contacts list.");
}
public synchronized Contact removeFromContacts(Node n)
private synchronized Contact removeFromContacts(Node n)
{
for (Contact c : this.contacts)
{
@ -223,7 +223,7 @@ public class KadBucketImpl implements KadBucket
}
}
public synchronized Contact removeFromReplacementCache(Node n)
private synchronized Contact removeFromReplacementCache(Node n)
{
for (Contact c : this.replacementCache)
{