Fixed duplicate result in kademlia search.
This commit is contained in:
parent
17dfadb6fd
commit
52f8ce2b3d
2 changed files with 6 additions and 3 deletions
|
@ -16,6 +16,9 @@ $(DHT_DIR)/dht.h:
|
||||||
dht.c: $(DEPS)
|
dht.c: $(DEPS)
|
||||||
ln -s $(DHT_DIR)/dht.c .
|
ln -s $(DHT_DIR)/dht.c .
|
||||||
|
|
||||||
|
kademlia_test: $(OBJS)
|
||||||
|
$(CC) -o kademlia_test kademlia_test.c kademlia.o dht.o $(CFLAGS) -pthread ../libp2p.a ../../c-multiaddr/libmultiaddr.a -lm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) dht.c
|
rm -f kademlia_test $(OBJS) dht.c
|
||||||
rm -rf $(DHT_DIR)
|
rm -rf $(DHT_DIR)
|
||||||
|
|
|
@ -104,7 +104,7 @@ callback(void *closure,
|
||||||
memcpy(&ipv4.port, data+4, 2);
|
memcpy(&ipv4.port, data+4, 2);
|
||||||
ipv4.port = ntohs(ipv4.port);
|
ipv4.port = ntohs(ipv4.port);
|
||||||
for (i = 0 ; i < rp->ipv4_count ; i++) {
|
for (i = 0 ; i < rp->ipv4_count ; i++) {
|
||||||
if (memcmp(&rp->ipv4[i], &ipv4, sizeof ipv4)) {
|
if (memcmp(&rp->ipv4[i], &ipv4, sizeof ipv4) == 0) {
|
||||||
return; // Alread in the list.
|
return; // Alread in the list.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ callback(void *closure,
|
||||||
memcpy(&ipv6.ip, data, 16);
|
memcpy(&ipv6.ip, data, 16);
|
||||||
memcpy(&ipv6.port, data+16, 2);
|
memcpy(&ipv6.port, data+16, 2);
|
||||||
for (i = 0 ; i < rp->ipv6_count ; i++) {
|
for (i = 0 ; i < rp->ipv6_count ; i++) {
|
||||||
if (memcmp(&rp->ipv6[i], &ipv6, sizeof ipv6)) {
|
if (memcmp(&rp->ipv6[i], &ipv6, sizeof ipv6) == 0) {
|
||||||
return; // Alread in the list.
|
return; // Alread in the list.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue