From 37337afc66590d42bbc0db9086fa81ab939c1ec3 Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Mon, 5 May 2014 12:46:44 +0530 Subject: [PATCH] There was an error when we recursively called the synchronized KadBucket.insert method - Fixed it by removing the recursion --- src/kademlia/core/DefaultConfiguration.java | 2 +- src/kademlia/core/KadServer.java | 2 ++ src/kademlia/operation/BucketRefreshOperation.java | 2 +- src/kademlia/routing/KadBucketImpl.java | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/kademlia/core/DefaultConfiguration.java b/src/kademlia/core/DefaultConfiguration.java index 6cb2ee8..1cc6520 100644 --- a/src/kademlia/core/DefaultConfiguration.java +++ b/src/kademlia/core/DefaultConfiguration.java @@ -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 = 3; + private final static int K = 10; private final static int RCSIZE = 3; private final static int STALE = 1; private final static String LOCAL_FOLDER = "kademlia"; diff --git a/src/kademlia/core/KadServer.java b/src/kademlia/core/KadServer.java index 5b9dbee..a3bd9bc 100644 --- a/src/kademlia/core/KadServer.java +++ b/src/kademlia/core/KadServer.java @@ -195,6 +195,8 @@ public class KadServer byte[] buffer = new byte[DATAGRAM_BUFFER_SIZE]; DatagramPacket packet = new DatagramPacket(buffer, buffer.length); socket.receive(packet); + + //System.out.println("Received packet of size: " + packet.getLength()); /* We've received a packet, now handle it */ try (ByteArrayInputStream bin = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength()); diff --git a/src/kademlia/operation/BucketRefreshOperation.java b/src/kademlia/operation/BucketRefreshOperation.java index 4a1d70f..9f364f0 100644 --- a/src/kademlia/operation/BucketRefreshOperation.java +++ b/src/kademlia/operation/BucketRefreshOperation.java @@ -57,7 +57,7 @@ public class BucketRefreshOperation implements Operation } catch (IOException e) { - e.printStackTrace(); + System.err.println("Bucket Refresh Operation Failed. Msg: " + e.getMessage()); } } }.start(); diff --git a/src/kademlia/routing/KadBucketImpl.java b/src/kademlia/routing/KadBucketImpl.java index c758b5f..39927cd 100644 --- a/src/kademlia/routing/KadBucketImpl.java +++ b/src/kademlia/routing/KadBucketImpl.java @@ -82,7 +82,7 @@ public class KadBucketImpl implements KadBucket if (stalest != null) { this.contacts.remove(stalest); - this.insert(c); + this.contacts.put(c, c); } else {