24 #define DIRCOLLATE_PRIVATE
46 #define ddmap_entry_free(e) \
47 FREE_AND_NULL(ddmap_entry_t, ddmap_entry_free_, (e))
70 return (
unsigned) siphash24g(ent->d,
sizeof(ent->d));
85 const uint8_t *rsa_sha1,
86 const uint8_t *ed25519)
119 if (NULL == vrs_lst) {
121 digestmap_set(dc->by_rsa_sha1,
id, vrs_lst);
124 vrs_lst[vote_num] = vrs;
133 memset(&search, 0,
sizeof(search));
135 found = HT_FIND(double_digest_map, &dc->by_both_ids, &search);
139 HT_INSERT(double_digest_map, &dc->by_both_ids, found);
141 vrs_lst = found->vrs_lst;
143 vrs_lst[vote_num] = vrs;
151 dircollator_t *dc = tor_malloc_zero(
sizeof(dircollator_t));
155 dc->n_votes = n_votes;
156 dc->n_authorities = n_authorities;
158 dc->by_rsa_sha1 = digestmap_new();
159 HT_INIT(double_digest_map, &dc->by_both_ids);
171 if (dc->by_collated_rsa_sha1 != dc->by_rsa_sha1)
172 digestmap_free(dc->by_collated_rsa_sha1, NULL);
174 digestmap_free(dc->by_rsa_sha1,
tor_free_);
175 smartlist_free(dc->all_rsa_sha1_lst);
178 for (e = HT_START(double_digest_map, &dc->by_both_ids);
179 e != NULL; e = next) {
181 next = HT_NEXT_RMV(double_digest_map, &dc->by_both_ids, e);
182 ddmap_entry_free(
this);
184 HT_CLEAR(double_digest_map, &dc->by_both_ids);
200 const int votenum = dc->next_vote_num++;
204 } SMARTLIST_FOREACH_END(vrs);
213 (void) consensus_method;
241 const int total_authorities = dc->n_authorities;
242 digestmap_t *rsa_digests = digestmap_new();
247 HT_FOREACH(iter, double_digest_map, &dc->by_both_ids) {
250 for (i = 0; i < dc->n_votes; ++i) {
251 if (ent->vrs_lst[i] != NULL)
257 if (n <= total_authorities / 2)
266 for (i = 0; i < dc->n_votes; ++i) {
267 if (ent->vrs_lst[i] != NULL) {
268 ent->vrs_lst[i]->ed25519_reflects_consensus = 1;
269 }
else if (vrs_lst2[i] && ! vrs_lst2[i]->has_ed25519_listing) {
270 ent->vrs_lst[i] = vrs_lst2[i];
275 digestmap_set(rsa_digests, (
char*)ent->d, ent->vrs_lst);
283 if (digestmap_get(rsa_digests, k) != NULL)
287 for (i = 0; i < dc->n_votes; ++i) {
288 if (vrs_lst[i] != NULL)
292 if (n <= total_authorities / 2)
295 digestmap_set(rsa_digests, k, vrs_lst);
299 dc->by_collated_rsa_sha1 = rsa_digests;
308 return smartlist_len(dc->all_rsa_sha1_lst);
323 tor_assert(idx < smartlist_len(dc->all_rsa_sha1_lst));
324 return digestmap_get(dc->by_collated_rsa_sha1,
325 smartlist_get(dc->all_rsa_sha1_lst, idx));
#define fast_memeq(a, b, c)
static void ddmap_entry_free_(ddmap_entry_t *e)
static unsigned ddmap_entry_eq(const ddmap_entry_t *a, const ddmap_entry_t *b)
int dircollator_n_routers(dircollator_t *dc)
void dircollator_free_(dircollator_t *dc)
static unsigned ddmap_entry_hash(const ddmap_entry_t *ent)
static ddmap_entry_t * ddmap_entry_new(int n_votes)
void dircollator_collate(dircollator_t *dc, int consensus_method)
void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v)
static void dircollator_add_routerstatus(dircollator_t *dc, int vote_num, networkstatus_t *vote, vote_routerstatus_t *vrs)
static void dircollator_collate_by_ed25519(dircollator_t *dc)
dircollator_t * dircollator_new(int n_votes, int n_authorities)
vote_routerstatus_t ** dircollator_get_votes_for_router(dircollator_t *dc, int idx)
static void ddmap_entry_set_digests(ddmap_entry_t *ent, const uint8_t *rsa_sha1, const uint8_t *ed25519)
Header file for dircollate.c.
Header file for dirvote.c.
HT_PROTOTYPE(hs_circuitmap_ht, circuit_t, hs_circuitmap_node, hs_circuit_hash_token, hs_circuits_have_same_token)
void tor_free_(void *mem)
#define DIGESTMAP_FOREACH_END
#define DIGESTMAP_FOREACH(map, keyvar, valtype, valvar)
Networkstatus consensus/vote structure.
void smartlist_sort_digests(smartlist_t *sl)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
char identity_digest[DIGEST_LEN]
uint8_t ed25519_id[ED25519_PUBKEY_LEN]
unsigned int has_ed25519_listing
unsigned int ed25519_reflects_consensus
Routerstatus (vote entry) structure.