summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-02-17 09:18:27 -0500
committerirungentoo <irungentoo@gmail.com>2014-02-17 09:18:27 -0500
commitf152d4c94dc8ecb567a6882b97f2ff95d56893ce (patch)
treef9951c1c1799a001c681302ef1bd8763c2dd7a21
parentbaa4a2f11d9178e7506b24acaf7973cf17e0877d (diff)
parent96e3f7053fcfafa1bdd497e94a663837a0188e5a (diff)
Merge branch 'lehi-dev' of https://github.com/lehitoskin/ProjectTox-Core into lehitoskin-lehi-dev
-rw-r--r--toxcore/assoc.c11
-rw-r--r--toxcore/assoc.h3
2 files changed, 9 insertions, 5 deletions
diff --git a/toxcore/assoc.c b/toxcore/assoc.c
index 2162ea78..adddb344 100644
--- a/toxcore/assoc.c
+++ b/toxcore/assoc.c
@@ -425,22 +425,23 @@ static uint8_t candidates_create_internal(Assoc *assoc, hash_t hash, uint8_t *id
425 * 1. seen bad, heard good 425 * 1. seen bad, heard good
426 * 2. seen good 426 * 2. seen good
427 * 3. used */ 427 * 3. used */
428 // enumerated lists are superior to magic numbers
428 if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT)) 429 if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT))
429 check = 3; 430 check = USED;
430 431
431 if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT)) 432 if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT))
432 check = 2; 433 check = SEENG;
433 else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT)) 434 else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT))
434 check = 1; 435 check = SEENB_HEARDG;
435 else 436 else
436 check = 0; 437 check = BAD;
437 438
438 if (!pos_check[check]) 439 if (!pos_check[check])
439 pos_check[check] = pos + 1; 440 pos_check[check] = pos + 1;
440 } 441 }
441 442
442 /* used > seen > heard > bad */ 443 /* used > seen > heard > bad */
443 size_t i, pos_max = used ? 3 : (seen ? 2 : 1); 444 size_t i, pos_max = used ? USED : (seen ? SEENG : SEENB_HEARDG);
444 445
445 for (i = 0; i < pos_max; i++) 446 for (i = 0; i < pos_max; i++)
446 if (pos_check[i]) { 447 if (pos_check[i]) {
diff --git a/toxcore/assoc.h b/toxcore/assoc.h
index b03792c3..9dbc75f2 100644
--- a/toxcore/assoc.h
+++ b/toxcore/assoc.h
@@ -7,6 +7,9 @@
7 7
8/* For the legalese parts, see tox.h. */ 8/* For the legalese parts, see tox.h. */
9 9
10/* enumerated lists are superior to magic numbers */
11enum NODE_STATUS { BAD, SEENB_HEARDG, SEENG, USED };
12
10/* 13/*
11 * Module to store currently unused ID <=> IP associations 14 * Module to store currently unused ID <=> IP associations
12 * for a potential future use 15 * for a potential future use