Merge remote-tracking branch 'public/bug23985_029' into maint-0.2.9
[tor.git] / src / or / dircollate.h
blob358c730cbbf762fecd75541a030bd6fa5bb7ea9a
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2016, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file dircollate.h
9 * \brief Header file for dircollate.c.
10 **/
12 #ifndef TOR_DIRCOLLATE_H
13 #define TOR_DIRCOLLATE_H
15 #include "testsupport.h"
16 #include "or.h"
18 typedef struct dircollator_s dircollator_t;
20 dircollator_t *dircollator_new(int n_votes, int n_authorities);
21 void dircollator_free(dircollator_t *obj);
22 void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v);
24 void dircollator_collate(dircollator_t *dc, int consensus_method);
26 int dircollator_n_routers(dircollator_t *dc);
27 vote_routerstatus_t **dircollator_get_votes_for_router(dircollator_t *dc,
28 int idx);
30 #ifdef DIRCOLLATE_PRIVATE
31 struct ddmap_entry_s;
32 typedef HT_HEAD(double_digest_map, ddmap_entry_s) double_digest_map_t;
33 /** A dircollator keeps track of all the routerstatus entries in a
34 * set of networkstatus votes, and matches them by an appropriate rule. */
35 struct dircollator_s {
36 /** True iff we have run the collation algorithm. */
37 int is_collated;
38 /** The total number of votes that we received. */
39 int n_votes;
40 /** The total number of authorities we acknowledge. */
41 int n_authorities;
43 /** The index which the next vote to be added to this collator should
44 * receive. */
45 int next_vote_num;
46 /** Map from RSA-SHA1 identity digest to an array of <b>n_votes</b>
47 * vote_routerstatus_t* pointers, such that the i'th member of the
48 * array is the i'th vote's entry for that RSA-SHA1 ID.*/
49 digestmap_t *by_rsa_sha1;
50 /** Map from <ed, RSA-SHA1> pair to an array similar to that used in
51 * by_rsa_sha1 above. We include <NULL,RSA-SHA1> entries for votes that
52 * say that there is no Ed key. */
53 struct double_digest_map by_both_ids;
55 /** One of two outputs created by collation: a map from RSA-SHA1
56 * identity digest to an array of the vote_routerstatus_t objects. Entries
57 * only exist in this map for identities that we should include in the
58 * consensus. */
59 digestmap_t *by_collated_rsa_sha1;
61 /** One of two outputs created by collation: a sorted array of RSA-SHA1
62 * identity digests .*/
63 smartlist_t *all_rsa_sha1_lst;
65 #endif
67 #endif