voting_schedule.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (c) 2018-2019, 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 "core/or/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. /** The valid-after time of the last live consensus that filled this voting
  41. * schedule. It's used to detect outdated voting schedules. */
  42. time_t live_consensus_valid_after;
  43. } voting_schedule_t;
  44. /* Public API. */
  45. extern voting_schedule_t voting_schedule;
  46. void voting_schedule_recalculate_timing(const or_options_t *options,
  47. time_t now);
  48. time_t voting_schedule_get_start_of_next_interval(time_t now,
  49. int interval,
  50. int offset);
  51. time_t voting_schedule_get_next_valid_after_time(void);
  52. #endif /* TOR_VOTING_SCHEDULE_H */