mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-12-23 00:01:46 +00:00
Content Lookup wasn't working! Fixed the issue! stupid "!" in the damn statement!
This commit is contained in:
parent
a259579f4a
commit
b1ab1be760
@ -64,7 +64,7 @@ public class StorageEntry
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Check that type matches */
|
||||
if ((params.getType() != null) && (!params.getType().equals(this.type)))
|
||||
{
|
||||
@ -72,7 +72,7 @@ public class StorageEntry
|
||||
}
|
||||
|
||||
/* Check that key matches */
|
||||
return ((params.getKey() != null) && (!params.getKey().equals(this.key)));
|
||||
return (params.getKey() != null) && (params.getKey().equals(this.key));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +76,7 @@ class StorageEntryManager
|
||||
{
|
||||
if (this.entries.containsKey(param.getKey()))
|
||||
{
|
||||
System.out.println("Does contain the key");
|
||||
/* Content with this key exist, check if any match the rest of the search criteria */
|
||||
for (StorageEntry e : this.entries.get(param.getKey()))
|
||||
{
|
||||
@ -86,6 +87,11 @@ class StorageEntryManager
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Does not contain the key");
|
||||
System.out.println(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,9 @@ public class ContentLookupReceiver implements Receiver
|
||||
{
|
||||
ContentLookupMessage msg = (ContentLookupMessage) incoming;
|
||||
this.localNode.getRoutingTable().insert(msg.getOrigin());
|
||||
|
||||
System.out.println("Received request for content with GetParameter" + msg.getParameters());
|
||||
System.out.println("Have Content? " + this.dht.contains(msg.getParameters()));
|
||||
|
||||
/* Check if we can have this data */
|
||||
if (this.dht.contains(msg.getParameters()))
|
||||
@ -49,6 +52,7 @@ public class ContentLookupReceiver implements Receiver
|
||||
* Return a the K closest nodes to this content identifier
|
||||
* We create a NodeLookupReceiver and let this receiver handle this operation
|
||||
*/
|
||||
System.out.println("We do not have this content");
|
||||
NodeLookupMessage lkpMsg = new NodeLookupMessage(msg.getOrigin(), msg.getParameters().getKey());
|
||||
new NodeLookupReceiver(server, localNode, this.config).receive(lkpMsg, comm);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package kademlia.operation;
|
||||
|
||||
import java.io.IOException;
|
||||
import kademlia.core.DefaultConfiguration;
|
||||
import kademlia.core.KadConfiguration;
|
||||
import kademlia.core.KadServer;
|
||||
import kademlia.exceptions.RoutingException;
|
||||
|
@ -9,7 +9,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import kademlia.core.DefaultConfiguration;
|
||||
import kademlia.core.GetParameter;
|
||||
import kademlia.core.KadConfiguration;
|
||||
import kademlia.core.KadServer;
|
||||
@ -35,10 +34,10 @@ public class ContentLookupOperation implements Operation, Receiver
|
||||
{
|
||||
|
||||
/* Constants */
|
||||
private static final Byte UNASKED = new Byte((byte) 0x00);
|
||||
private static final Byte AWAITING = new Byte((byte) 0x01);
|
||||
private static final Byte ASKED = new Byte((byte) 0x02);
|
||||
private static final Byte FAILED = new Byte((byte) 0x03);
|
||||
private static final Byte UNASKED = (byte) 0x00;
|
||||
private static final Byte AWAITING = (byte) 0x01;
|
||||
private static final Byte ASKED = (byte) 0x02;
|
||||
private static final Byte FAILED = (byte) 0x03;
|
||||
|
||||
private final KadServer server;
|
||||
private final Node localNode;
|
||||
@ -194,7 +193,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
||||
int comm = server.sendMessage(n, lookupMessage, this);
|
||||
|
||||
this.nodes.put(n, AWAITING);
|
||||
this.messagesTransiting.put(new Integer(comm), n);
|
||||
this.messagesTransiting.put(comm, n);
|
||||
}
|
||||
|
||||
/* We're not finished as yet, return false */
|
||||
@ -277,7 +276,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
||||
this.nodes.put(origin, ASKED);
|
||||
|
||||
/* Remove this msg from messagesTransiting since it's completed now */
|
||||
this.messagesTransiting.remove(new Integer(comm));
|
||||
this.messagesTransiting.remove(comm);
|
||||
|
||||
/* Add the received nodes to our nodes list to query */
|
||||
this.addNodes(msg.getNodes());
|
||||
@ -306,7 +305,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
||||
/* Mark this node as failed */
|
||||
this.nodes.put(n, FAILED);
|
||||
this.localNode.getRoutingTable().remove(n);
|
||||
this.messagesTransiting.remove(new Integer(comm));
|
||||
this.messagesTransiting.remove(comm);
|
||||
|
||||
this.askNodesorFinish();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user