dircollate.h 2.3 KB

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