Browse Source

r13418@catbus: nickm | 2007-06-14 13:29:21 -0400
Adjust networkstatus_compute_consensus to take an argument saying how many voters there _should_ be.


svn:r10634

Nick Mathewson 18 years ago
parent
commit
9e944d07f8
3 changed files with 7 additions and 3 deletions
  1. 5 2
      src/or/dirvote.c
  2. 1 0
      src/or/or.h
  3. 1 1
      src/or/test.c

+ 5 - 2
src/or/dirvote.c

@@ -197,6 +197,8 @@ compare_votes(const vote_routerstatus_t *a, const vote_routerstatus_t *b)
     return r;
   if ((r = strcmp(b->status.nickname, a->status.nickname)))
     return r;
+  if ((r = (((int)b->status.addr) - ((int)a->status.addr))))
+    return r;
   if ((r = (((int)b->status.or_port) - ((int)a->status.or_port))))
     return r;
   if ((r = (((int)b->status.dir_port) - ((int)a->status.dir_port))))
@@ -263,6 +265,7 @@ hash_list_members(char *digest_out, smartlist_t *lst)
 /** DOCDOC */
 char *
 networkstatus_compute_consensus(smartlist_t *votes,
+                                int total_authorities,
                                 crypto_pk_env_t *identity_key,
                                 crypto_pk_env_t *signing_key)
 {
@@ -273,7 +276,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
   int vote_seconds, dist_seconds;
   char *client_versions = NULL, *server_versions = NULL;
   smartlist_t *flags;
-  int total_authorities = smartlist_len(votes); /*XXXX020 not right. */
+  tor_assert(total_authorities >= smartlist_len(votes));
 
   if (!smartlist_len(votes)) {
     log_warn(LD_DIR, "Can't compute a consensus from no votes.");
@@ -516,7 +519,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
         }
         if (rs->flags & (U64_LITERAL(1) << named_flag[v_sl_idx])) {
           if (chosen_name && strcmp(chosen_name, rs->status.nickname))
-            naming_conflict = 1;
+            naming_conflict = 1; /* XXXX020 warn? */
           chosen_name = rs->status.nickname;
         }
 

+ 1 - 0
src/or/or.h

@@ -2758,6 +2758,7 @@ format_networkstatus_vote(crypto_pk_env_t *private_key,
 
 void networkstatus_vote_free(networkstatus_vote_t *ns);
 char *networkstatus_compute_consensus(smartlist_t *votes,
+                                      int total_authorities,
                                       crypto_pk_env_t *identity_key,
                                       crypto_pk_env_t *signing_key);
 networkstatus_voter_info_t *networkstatus_get_voter_by_id(

+ 1 - 1
src/or/test.c

@@ -2386,7 +2386,7 @@ test_v3_networkstatus(void)
   smartlist_add(votes, v3);
   smartlist_add(votes, v1);
   smartlist_add(votes, v2);
-  consensus_text = networkstatus_compute_consensus(votes,
+  consensus_text = networkstatus_compute_consensus(votes, 3,
                                                    cert3->identity_key,
                                                    sign_skey_3);
   test_assert(consensus_text);