dircollate.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-2017, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file dircollate.h
  8. * \brief Header file for dircollate.c.
  9. **/
  10. #ifndef TOR_DIRCOLLATE_H
  11. #define TOR_DIRCOLLATE_H
  12. #include "testsupport.h"
  13. #include "or.h"
  14. typedef struct dircollator_s dircollator_t;
  15. dircollator_t *dircollator_new(int n_votes, int n_authorities);
  16. void dircollator_free_(dircollator_t *obj);
  17. #define dircollator_free(c) \
  18. FREE_AND_NULL(dircollator_t, dircollator_free_, (c))
  19. void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v);
  20. void dircollator_collate(dircollator_t *dc, int consensus_method);
  21. int dircollator_n_routers(dircollator_t *dc);
  22. vote_routerstatus_t **dircollator_get_votes_for_router(dircollator_t *dc,
  23. int idx);
  24. #ifdef DIRCOLLATE_PRIVATE
  25. struct ddmap_entry_s;
  26. typedef HT_HEAD(double_digest_map, ddmap_entry_s) double_digest_map_t;
  27. /** A dircollator keeps track of all the routerstatus entries in a
  28. * set of networkstatus votes, and matches them by an appropriate rule. */
  29. struct dircollator_s {
  30. /** True iff we have run the collation algorithm. */
  31. int is_collated;
  32. /** The total number of votes that we received. */
  33. int n_votes;
  34. /** The total number of authorities we acknowledge. */
  35. int n_authorities;
  36. /** The index which the next vote to be added to this collator should
  37. * receive. */
  38. int next_vote_num;
  39. /** Map from RSA-SHA1 identity digest to an array of <b>n_votes</b>
  40. * vote_routerstatus_t* pointers, such that the i'th member of the
  41. * array is the i'th vote's entry for that RSA-SHA1 ID.*/
  42. digestmap_t *by_rsa_sha1;
  43. /** Map from <ed, RSA-SHA1> pair to an array similar to that used in
  44. * by_rsa_sha1 above. We include <NULL,RSA-SHA1> entries for votes that
  45. * say that there is no Ed key. */
  46. struct double_digest_map by_both_ids;
  47. /** One of two outputs created by collation: a map from RSA-SHA1
  48. * identity digest to an array of the vote_routerstatus_t objects. Entries
  49. * only exist in this map for identities that we should include in the
  50. * consensus. */
  51. digestmap_t *by_collated_rsa_sha1;
  52. /** One of two outputs created by collation: a sorted array of RSA-SHA1
  53. * identity digests .*/
  54. smartlist_t *all_rsa_sha1_lst;
  55. };
  56. #endif /* defined(DIRCOLLATE_PRIVATE) */
  57. #endif /* !defined(TOR_DIRCOLLATE_H) */