Merge branch 'lehi-dev' of https://github.com/lehitoskin/ProjectTox-Core into lehitoskin-lehi-dev

This commit is contained in:
irungentoo 2014-02-17 09:18:27 -05:00
commit f152d4c94d
2 changed files with 9 additions and 5 deletions

View File

@ -425,22 +425,23 @@ static uint8_t candidates_create_internal(Assoc *assoc, hash_t hash, uint8_t *id
* 1. seen bad, heard good * 1. seen bad, heard good
* 2. seen good * 2. seen good
* 3. used */ * 3. used */
// enumerated lists are superior to magic numbers
if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT)) if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT))
check = 3; check = USED;
if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT)) if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT))
check = 2; check = SEENG;
else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT)) else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT))
check = 1; check = SEENB_HEARDG;
else else
check = 0; check = BAD;
if (!pos_check[check]) if (!pos_check[check])
pos_check[check] = pos + 1; pos_check[check] = pos + 1;
} }
/* used > seen > heard > bad */ /* used > seen > heard > bad */
size_t i, pos_max = used ? 3 : (seen ? 2 : 1); size_t i, pos_max = used ? USED : (seen ? SEENG : SEENB_HEARDG);
for (i = 0; i < pos_max; i++) for (i = 0; i < pos_max; i++)
if (pos_check[i]) { if (pos_check[i]) {

View File

@ -7,6 +7,9 @@
/* For the legalese parts, see tox.h. */ /* For the legalese parts, see tox.h. */
/* enumerated lists are superior to magic numbers */
enum NODE_STATUS { BAD, SEENB_HEARDG, SEENG, USED };
/* /*
* Module to store currently unused ID <=> IP associations * Module to store currently unused ID <=> IP associations
* for a potential future use * for a potential future use