voting_schedule.h 2.1 KB

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