summaryrefslogtreecommitdiff
path: root/toxcore/assoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/assoc.c')
-rw-r--r--toxcore/assoc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/toxcore/assoc.c b/toxcore/assoc.c
index 3dbeba51..2e03dabe 100644
--- a/toxcore/assoc.c
+++ b/toxcore/assoc.c
@@ -510,20 +510,18 @@ static uint8_t candidates_create_new(const Assoc *assoc, hash_t hash, const uint
510 510
511static void client_id_self_update(Assoc *assoc) 511static void client_id_self_update(Assoc *assoc)
512{ 512{
513 if (assoc->self_hash || !assoc->self_client_id) 513 if (assoc->self_hash)
514 return; 514 return;
515 515
516 if (!assoc->self_hash) { 516 size_t i, sum = 0;
517 size_t i, sum = 0;
518 517
519 for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) 518 for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++)
520 sum |= assoc->self_client_id[i]; 519 sum |= assoc->self_client_id[i];
521 520
522 if (!sum) 521 if (!sum)
523 return; 522 return;
524 523
525 assoc->self_hash = id_hash(assoc, assoc->self_client_id); 524 assoc->self_hash = id_hash(assoc, assoc->self_client_id);
526 }
527 525
528 LOGGER_DEBUG("id is now set, purging cache of self-references"); 526 LOGGER_DEBUG("id is now set, purging cache of self-references");
529 527
@@ -532,7 +530,7 @@ static void client_id_self_update(Assoc *assoc)
532 */ 530 */
533 bucket_t b_id = candidates_id_bucket(assoc, assoc->self_client_id); 531 bucket_t b_id = candidates_id_bucket(assoc, assoc->self_client_id);
534 candidates_bucket *cnd_bckt = &assoc->candidates[b_id]; 532 candidates_bucket *cnd_bckt = &assoc->candidates[b_id];
535 size_t i, pos = assoc->self_hash % assoc->candidates_bucket_size; 533 size_t pos = assoc->self_hash % assoc->candidates_bucket_size;
536 534
537 for (i = 0; i < HASH_COLLIDE_COUNT; pos = hash_collide(assoc, pos), i++) { 535 for (i = 0; i < HASH_COLLIDE_COUNT; pos = hash_collide(assoc, pos), i++) {
538 Client_entry *entry = &cnd_bckt->list[pos]; 536 Client_entry *entry = &cnd_bckt->list[pos];