aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirvote.c
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2008-08-05 18:54:23 +0000
committerPeter Palfrader <peter@palfrader.org>2008-08-05 18:54:23 +0000
commit0cfb68454e8ac7097c9784f76ec174e1bc0cede1 (patch)
tree146d004e39e706130b84a685eeb5a889871f2ad6 /src/or/dirvote.c
parent4cb2adcd4fc64b7e797a7eb5f4871a9b856f198b (diff)
downloadtor-0cfb68454e8ac7097c9784f76ec174e1bc0cede1.tar
tor-0cfb68454e8ac7097c9784f76ec174e1bc0cede1.tar.gz
Document that we break ties in favor of smaller SD digest if there are still ties after comparing the published timestamp
svn:r16432
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r--src/or/dirvote.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 6a705bc84..42710a40d 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -337,7 +337,8 @@ _compare_vote_rs(const void **_a, const void **_b)
/** Given a list of vote_routerstatus_t, all for the same router identity,
* return whichever is most frequent, breaking ties in favor of more
- * recently published vote_routerstatus_t.
+ * recently published vote_routerstatus_t and in case of ties there,
+ * in favour of smaller descriptor digest.
*/
static vote_routerstatus_t *
compute_routerstatus_consensus(smartlist_t *votes)
@@ -346,6 +347,10 @@ compute_routerstatus_consensus(smartlist_t *votes)
int most_n = 0, cur_n = 0;
time_t most_published = 0;
+ /* _compare_vote_rs() sorts the items by identity digest (all the same),
+ * then by SD digest. That way, if we have a tie that the published_on
+ * date cannot tie, we use the descriptor with the smaller digest.
+ */
smartlist_sort(votes, _compare_vote_rs);
SMARTLIST_FOREACH(votes, vote_routerstatus_t *, rs,
{