diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-10-13 17:06:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-10-15 15:17:13 -0400 |
commit | 851a980065e6b2df8d7cb35a22d0675b8918214b (patch) | |
tree | 46c56b5bf6fbecfda5b2b6d860593535279f59ea /src/or/dirvote.c | |
parent | a19981725d167927d32ef2a31c7a7968be3d95b6 (diff) | |
download | tor-851a980065e6b2df8d7cb35a22d0675b8918214b.tar.gz tor-851a980065e6b2df8d7cb35a22d0675b8918214b.zip |
Actually remember all the consensus types when we are done generating them.
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index d64e4d53a2..e50a875411 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -421,13 +421,13 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method, microdesc_digest256_out) { smartlist_t *digests = smartlist_create(); const char *best_microdesc_digest; - SMARTLIST_FOREACH(votes, vote_routerstatus_t *, rs, { + SMARTLIST_FOREACH_BEGIN(votes, vote_routerstatus_t *, rs) { char d[DIGEST256_LEN]; if (compare_vote_rs(rs, most)) continue; if (!vote_routerstatus_find_microdesc_hash(d, rs, consensus_method)) smartlist_add(digests, tor_memdup(d, sizeof(d))); - }); + } SMARTLIST_FOREACH_END(rs); smartlist_sort_digests256(digests); best_microdesc_digest = smartlist_get_most_frequent_digest256(digests); if (best_microdesc_digest) @@ -2602,20 +2602,25 @@ dirvote_add_signatures(const char *detached_signatures_body, static int dirvote_publish_consensus(void) { - /* Can we actually publish it yet? */ - if (!pending_consensuses[FLAV_NS].consensus || - networkstatus_check_consensus_signature( - pending_consensuses[FLAV_NS].consensus, 1)<0) { - log_warn(LD_DIR, "Not enough info to publish pending consensus"); - return -1; - } + int i; - /* XXXXXX NMNMNM */ - if (networkstatus_set_current_consensus( - pending_consensuses[FLAV_NS].body, 0)) - log_warn(LD_DIR, "Error publishing consensus"); - else - log_notice(LD_DIR, "Consensus published."); + /* Now remember all the other consensuses as if we were a directory cache. */ + for (i = 0; i < N_CONSENSUS_FLAVORS; ++i) { + pending_consensus_t *pending = &pending_consensuses[i]; + const char *name; + name = networkstatus_get_flavor_name(i); + tor_assert(name); + if (!pending->consensus || + networkstatus_check_consensus_signature(pending->consensus, 1)<0) { + log_warn(LD_DIR, "Not enough info to publish pending %s consensus",name); + continue; + } + + if (networkstatus_set_current_consensus(pending->body, name, 0)) + log_warn(LD_DIR, "Error publishing %s consensus", name); + else + log_notice(LD_DIR, "Published %s consensus", name); + } return 0; } |