summaryrefslogtreecommitdiff
path: root/toxcore/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/ping.c')
-rw-r--r--toxcore/ping.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/toxcore/ping.c b/toxcore/ping.c
index 17fb3e9e..6a480f6f 100644
--- a/toxcore/ping.c
+++ b/toxcore/ping.c
@@ -287,15 +287,8 @@ int add_to_ping(PING *ping, const uint8_t *public_key, IP_Port ip_port)
287 } 287 }
288 } 288 }
289 289
290 unsigned int r = rand(); 290 if (add_to_list(ping->to_ping, MAX_TO_PING, public_key, ip_port, ping->dht->self_public_key))
291 291 return 0;
292 for (i = 0; i < MAX_TO_PING; ++i) {
293 if (id_closest(ping->dht->self_public_key, ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key) == 2) {
294 memcpy(ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key, crypto_box_PUBLICKEYBYTES);
295 ipport_copy(&ping->to_ping[(i + r) % MAX_TO_PING].ip_port, &ip_port);
296 return 0;
297 }
298 }
299 292
300 return -1; 293 return -1;
301} 294}