dirvote_common.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2018, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file dirvote_common.h
  5. * \brief Header file for dirvote_common.c.
  6. **/
  7. #ifndef TOR_DIRVOTE_COMMON_H
  8. #define TOR_DIRVOTE_COMMON_H
  9. #include "or.h"
  10. /* Dirauth module. */
  11. #include "dirauth/dirvote.h"
  12. /** Scheduling information for a voting interval. */
  13. typedef struct {
  14. /** When do we generate and distribute our vote for this interval? */
  15. time_t voting_starts;
  16. /** When do we send an HTTP request for any votes that we haven't
  17. * been posted yet?*/
  18. time_t fetch_missing_votes;
  19. /** When do we give up on getting more votes and generate a consensus? */
  20. time_t voting_ends;
  21. /** When do we send an HTTP request for any signatures we're expecting to
  22. * see on the consensus? */
  23. time_t fetch_missing_signatures;
  24. /** When do we publish the consensus? */
  25. time_t interval_starts;
  26. /* True iff we have generated and distributed our vote. */
  27. int have_voted;
  28. /* True iff we've requested missing votes. */
  29. int have_fetched_missing_votes;
  30. /* True iff we have built a consensus and sent the signatures around. */
  31. int have_built_consensus;
  32. /* True iff we've fetched missing signatures. */
  33. int have_fetched_missing_signatures;
  34. /* True iff we have published our consensus. */
  35. int have_published_consensus;
  36. /* True iff this voting schedule was set on demand meaning not through the
  37. * normal vote operation of a dirauth or when a consensus is set. This only
  38. * applies to a directory authority that needs to recalculate the voting
  39. * timings only for the first vote even though this object was initilized
  40. * prior to voting. */
  41. int created_on_demand;
  42. } voting_schedule_t;
  43. /* Public API. */
  44. extern voting_schedule_t voting_schedule;
  45. void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
  46. time_t dirvote_get_start_of_next_interval(time_t now,
  47. int interval,
  48. int offset);
  49. time_t dirvote_get_next_valid_after_time(void);
  50. document_signature_t *dirvote_get_voter_sig_by_alg(
  51. const networkstatus_voter_info_t *voter,
  52. digest_algorithm_t alg);
  53. #endif /* TOR_DIRVOTE_COMMON_H */