mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Send get nodes more to closer nodes than further nodes.
This commit is contained in:
parent
9b9d442e17
commit
4cfafe8310
|
@ -1422,12 +1422,20 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
|
|||
if (rand_node >= num_nodes) {
|
||||
rand_node = rand_node % num_nodes;
|
||||
|
||||
if ((num_nodes - 1) != rand_node) {
|
||||
rand_node += rand() % (num_nodes - (rand_node + 1));
|
||||
}
|
||||
|
||||
if (memcmp(client_list[rand_node]->public_key, public_key, crypto_box_PUBLICKEYBYTES) != 0) {
|
||||
uint8_t get_pk[crypto_box_PUBLICKEYBYTES];
|
||||
find_midpoint(get_pk, client_list[rand_node]->public_key, public_key);
|
||||
getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, get_pk, NULL);
|
||||
}
|
||||
} else {
|
||||
if ((num_nodes - 1) != rand_node) {
|
||||
rand_node += rand() % (num_nodes - (rand_node + 1));
|
||||
}
|
||||
|
||||
getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, public_key, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user