mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-12-22 15:51:46 +00:00
Few minor changes
This commit is contained in:
parent
c23edf2cb9
commit
9e94a225fe
@ -50,7 +50,7 @@ public interface KadContent
|
||||
* Each object is responsible for transforming itself to byte format since the
|
||||
* structure of methods may differ.
|
||||
*
|
||||
* @return byte[] The content in byte format
|
||||
* @return The content in byte format
|
||||
*/
|
||||
public byte[] toSerializedForm();
|
||||
|
||||
@ -59,7 +59,7 @@ public interface KadContent
|
||||
*
|
||||
* @param data The object in byte format
|
||||
*
|
||||
* @return A new object from the given byte[]
|
||||
* @return A new object from the given
|
||||
*/
|
||||
public KadContent fromSerializedForm(byte[] data);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ public class SimpleReceiver implements Receiver
|
||||
@Override
|
||||
public void receive(Message incoming, int conversationId)
|
||||
{
|
||||
|
||||
//System.out.println("Received message: " + incoming);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeout(int conversationId) throws IOException
|
||||
{
|
||||
|
||||
//System.out.println("SimpleReceiver message timeout.");
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
private final KademliaNode localNode;
|
||||
private final KadConfiguration config;
|
||||
|
||||
private boolean error;
|
||||
|
||||
private final Message lookupMessage; // Message sent to each peer
|
||||
private final Map<Node, String> nodes;
|
||||
|
||||
@ -87,8 +85,6 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
{
|
||||
try
|
||||
{
|
||||
error = true;
|
||||
|
||||
/* Set the local node as already asked */
|
||||
nodes.put(this.localNode.getNode(), ASKED);
|
||||
|
||||
@ -100,7 +96,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
|
||||
/* If we haven't finished as yet, wait for a maximum of config.operationTimeout() time */
|
||||
int totalTimeWaited = 0;
|
||||
int timeInterval = 10; // We re-check every 300 milliseconds
|
||||
int timeInterval = 10; // We re-check every n milliseconds
|
||||
while (totalTimeWaited < this.config.operationTimeout())
|
||||
{
|
||||
if (!this.askNodesorFinish())
|
||||
@ -114,17 +110,6 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no need to throw an exception here!
|
||||
* If the operation times out means we didn't get replies from all nodes,
|
||||
* so lets just simply return the K-Closest nodes we knoe
|
||||
*/
|
||||
// if (error)
|
||||
// {
|
||||
// /* If we still haven't received any responses by then, do a routing timeout */
|
||||
// throw new RoutingException("Node Lookup Timeout.");
|
||||
// }
|
||||
|
||||
/* Now after we've finished, we would have an idea of offline nodes, lets update our routing table */
|
||||
this.localNode.getRoutingTable().setUnresponsiveContacts(this.getFailedNodes());
|
||||
|
||||
@ -182,7 +167,6 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
if (unasked.isEmpty() && this.messagesTransiting.isEmpty())
|
||||
{
|
||||
/* We have no unasked nodes nor any messages in transit, we're finished! */
|
||||
error = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user