From 104f20775f26537afecab31315fe3c47332bf59c Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Sat, 22 Mar 2014 12:41:46 +0530 Subject: [PATCH] Fixed the bug that was causing the problem when adding the local node to the routing table when the routing table is created. - The problem was that we were creating the RoutingTable before the Node initialization was finished, which was causing some problems since the RoutingTable needs the NodeId which is not available until after the Node initialization --- src/kademlia/node/Node.java | 6 +----- src/kademlia/routing/RoutingTable.java | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/kademlia/node/Node.java b/src/kademlia/node/Node.java index f6cc88f..6dd7e16 100644 --- a/src/kademlia/node/Node.java +++ b/src/kademlia/node/Node.java @@ -26,17 +26,13 @@ public class Node implements Streamable private transient RoutingTable routingTable; - - { - this.routingTable = new RoutingTable(this); - } - public Node(NodeId nid, InetAddress ip, int port) { this.nodeId = nid; this.inetAddress = ip; this.port = port; this.strRep = this.nodeId.toString(); + this.routingTable = new RoutingTable(this); } /** diff --git a/src/kademlia/routing/RoutingTable.java b/src/kademlia/routing/RoutingTable.java index 1c410a2..1d99287 100644 --- a/src/kademlia/routing/RoutingTable.java +++ b/src/kademlia/routing/RoutingTable.java @@ -32,8 +32,8 @@ public class RoutingTable /* Initialize all of the buckets to a specific depth */ this.initialize(); - /* @todo Insert the local node */ - //this.insert(localNode); + /* Insert the local node */ + this.insert(localNode); } /**