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