diff options
-rw-r--r-- | toxcore/DHT.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index d2cdb87b..c703be4a 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -674,10 +674,10 @@ static int cmp_dht_entry(const void *a, const void *b) | |||
674 | * return 0 if node can't be stored. | 674 | * return 0 if node can't be stored. |
675 | * return 1 if it can. | 675 | * return 1 if it can. |
676 | */ | 676 | */ |
677 | static unsigned int store_node_ok(const Client_data *client, const uint8_t *public_key, const uint8_t *comp_client_id) | 677 | static unsigned int store_node_ok(const Client_data *client, const uint8_t *public_key, const uint8_t *comp_public_key) |
678 | { | 678 | { |
679 | if ((is_timeout(client->assoc4.timestamp, BAD_NODE_TIMEOUT) && is_timeout(client->assoc6.timestamp, BAD_NODE_TIMEOUT)) | 679 | if ((is_timeout(client->assoc4.timestamp, BAD_NODE_TIMEOUT) && is_timeout(client->assoc6.timestamp, BAD_NODE_TIMEOUT)) |
680 | || (id_closest(comp_client_id, client->public_key, public_key) == 2)) { | 680 | || (id_closest(comp_public_key, client->public_key, public_key) == 2)) { |
681 | return 1; | 681 | return 1; |
682 | } else { | 682 | } else { |
683 | return 0; | 683 | return 0; |
@@ -687,13 +687,13 @@ static unsigned int store_node_ok(const Client_data *client, const uint8_t *publ | |||
687 | /* Replace a first bad (or empty) node with this one | 687 | /* Replace a first bad (or empty) node with this one |
688 | * or replace a possibly bad node (tests failed or not done yet) | 688 | * or replace a possibly bad node (tests failed or not done yet) |
689 | * that is further than any other in the list | 689 | * that is further than any other in the list |
690 | * from the comp_client_id | 690 | * from the comp_public_key |
691 | * or replace a good node that is further | 691 | * or replace a good node that is further |
692 | * than any other in the list from the comp_client_id | 692 | * than any other in the list from the comp_public_key |
693 | * and further than public_key. | 693 | * and further than public_key. |
694 | * | 694 | * |
695 | * Do not replace any node if the list has no bad or possibly bad nodes | 695 | * Do not replace any node if the list has no bad or possibly bad nodes |
696 | * and all nodes in the list are closer to comp_client_id | 696 | * and all nodes in the list are closer to comp_public_key |
697 | * than public_key. | 697 | * than public_key. |
698 | * | 698 | * |
699 | * returns True(1) when the item was stored, False(0) otherwise */ | 699 | * returns True(1) when the item was stored, False(0) otherwise */ |
@@ -701,17 +701,17 @@ static int replace_all( Client_data *list, | |||
701 | uint16_t length, | 701 | uint16_t length, |
702 | const uint8_t *public_key, | 702 | const uint8_t *public_key, |
703 | IP_Port ip_port, | 703 | IP_Port ip_port, |
704 | const uint8_t *comp_client_id ) | 704 | const uint8_t *comp_public_key ) |
705 | { | 705 | { |
706 | if ((ip_port.ip.family != AF_INET) && (ip_port.ip.family != AF_INET6)) | 706 | if ((ip_port.ip.family != AF_INET) && (ip_port.ip.family != AF_INET6)) |
707 | return 0; | 707 | return 0; |
708 | 708 | ||
709 | memcpy(cmp_public_key, comp_client_id, crypto_box_PUBLICKEYBYTES); | 709 | memcpy(cmp_public_key, comp_public_key, crypto_box_PUBLICKEYBYTES); |
710 | qsort(list, length, sizeof(Client_data), cmp_dht_entry); | 710 | qsort(list, length, sizeof(Client_data), cmp_dht_entry); |
711 | 711 | ||
712 | Client_data *client = &list[0]; | 712 | Client_data *client = &list[0]; |
713 | 713 | ||
714 | if (store_node_ok(client, public_key, comp_client_id)) { | 714 | if (store_node_ok(client, public_key, comp_public_key)) { |
715 | IPPTsPng *ipptp_write = NULL; | 715 | IPPTsPng *ipptp_write = NULL; |
716 | IPPTsPng *ipptp_clear = NULL; | 716 | IPPTsPng *ipptp_clear = NULL; |
717 | 717 | ||