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
This commit is contained in:
Nick Mathewson 2007-06-17 15:10:23 +00:00
parent 547073bedc
commit 9e944d07f8
3 changed files with 7 additions and 3 deletions

View File

@ -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;
}

View File

@ -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(

View File

@ -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);