diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/DHT.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index fb6a9e3a..052b74ff 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -65,11 +65,6 @@ | |||
65 | /* Number of get node requests to send to quickly find close nodes. */ | 65 | /* Number of get node requests to send to quickly find close nodes. */ |
66 | #define MAX_BOOTSTRAP_TIMES 5 | 66 | #define MAX_BOOTSTRAP_TIMES 5 |
67 | 67 | ||
68 | static uint8_t calc_dist(uint8_t a, uint8_t b) | ||
69 | { | ||
70 | return a ^ b; | ||
71 | } | ||
72 | |||
73 | /* Compares pk1 and pk2 with pk. | 68 | /* Compares pk1 and pk2 with pk. |
74 | * | 69 | * |
75 | * return 0 if both are same distance. | 70 | * return 0 if both are same distance. |
@@ -80,12 +75,11 @@ int id_closest(const uint8_t *pk, const uint8_t *pk1, const uint8_t *pk2) | |||
80 | { | 75 | { |
81 | size_t i; | 76 | size_t i; |
82 | uint8_t distance1, distance2; | 77 | uint8_t distance1, distance2; |
83 | _Bool d1_abs = 0, d2_abs = 0; | ||
84 | 78 | ||
85 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) { | 79 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) { |
86 | 80 | ||
87 | distance1 = calc_dist(pk[i], pk1[i]); | 81 | distance1 = pk[i] ^ pk1[i]; |
88 | distance2 = calc_dist(pk[i], pk2[i]); | 82 | distance2 = pk[i] ^ pk2[i]; |
89 | 83 | ||
90 | if (distance1 < distance2) | 84 | if (distance1 < distance2) |
91 | return 1; | 85 | return 1; |