[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17008: {tor} v3 authorities write down all the votes they used for the co (tor/trunk/src/or)



Author: arma
Date: 2008-09-29 19:13:43 -0400 (Mon, 29 Sep 2008)
New Revision: 17008

Modified:
   tor/trunk/src/or/dirvote.c
Log:
v3 authorities write down all the votes they used for the consensus
to the datadir, for debugging.


Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2008-09-29 22:34:22 UTC (rev 17007)
+++ tor/trunk/src/or/dirvote.c	2008-09-29 23:13:43 UTC (rev 17008)
@@ -1789,7 +1789,7 @@
     goto err;
   }
 
-  /* Now see whether we already h<ave a vote from this authority.*/
+  /* Now see whether we already have a vote from this authority. */
   SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v, {
       if (! memcmp(v->vote->cert->cache_info.identity_digest,
                    vote->cert->cache_info.identity_digest,
@@ -1874,14 +1874,14 @@
 /** Try to compute a v3 networkstatus consensus from the currently pending
  * votes.  Return 0 on success, -1 on failure.  Store the consensus in
  * pending_consensus: it won't be ready to be published until we have
- * everybody else's signatures collected too. (V3 Authoritity only) */
+ * everybody else's signatures collected too. (V3 Authority only) */
 static int
 dirvote_compute_consensus(void)
 {
   /* Have we got enough votes to try? */
   int n_votes, n_voters;
-  smartlist_t *votes = NULL;
-  char *consensus_body = NULL, *signatures = NULL;
+  smartlist_t *votes = NULL, *votestrings = NULL;
+  char *consensus_body = NULL, *signatures = NULL, *votefile;
   networkstatus_t *consensus = NULL;
   authority_cert_t *my_cert;
 
@@ -1902,9 +1902,23 @@
   }
 
   votes = smartlist_create();
+  votestrings = smartlist_create();
   SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v,
-                    smartlist_add(votes, v->vote));
+    {
+      sized_chunk_t *c = tor_malloc(sizeof(sized_chunk_t));
+      c->bytes = v->vote_body->dir;
+      c->len = v->vote_body->dir_len;
+      smartlist_add(votestrings, c); /* collect strings to write to disk */
 
+      smartlist_add(votes, v->vote); /* collect votes to compute consensus */
+    });
+
+  votefile = get_datadir_fname("v3-status-votes");
+  write_chunks_to_file(votefile, votestrings, 0);
+  tor_free(votefile);
+  SMARTLIST_FOREACH(votestrings, sized_chunk_t *, c, tor_free(c));
+  smartlist_free(votestrings);
+
   {
     char legacy_dbuf[DIGEST_LEN];
     crypto_pk_env_t *legacy_sign=NULL;