Tor  0.4.7.0-alpha-dev
voting_schedule.h
Go to the documentation of this file.
1 /* Copyright (c) 2018-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * \file voting_schedule.h
6  * \brief Header file for voting_schedule.c.
7  **/
8 
9 #ifndef TOR_VOTING_SCHEDULE_H
10 #define TOR_VOTING_SCHEDULE_H
11 
12 #include "core/or/or.h"
13 
14 #ifdef HAVE_MODULE_DIRAUTH
15 
16 /** Scheduling information for a voting interval. */
17 typedef struct {
18  /** When do we generate and distribute our vote for this interval? */
19  time_t voting_starts;
20  /** When do we send an HTTP request for any votes that we haven't
21  * been posted yet?*/
22  time_t fetch_missing_votes;
23  /** When do we give up on getting more votes and generate a consensus? */
24  time_t voting_ends;
25  /** When do we send an HTTP request for any signatures we're expecting to
26  * see on the consensus? */
27  time_t fetch_missing_signatures;
28  /** When do we publish the consensus? */
29  time_t interval_starts;
30 
31  /** Our computed dirauth interval */
32  int interval;
33 
34  /** True iff we have generated and distributed our vote. */
35  int have_voted;
36  /** True iff we've requested missing votes. */
37  int have_fetched_missing_votes;
38  /** True iff we have built a consensus and sent the signatures around. */
39  int have_built_consensus;
40  /** True iff we've fetched missing signatures. */
41  int have_fetched_missing_signatures;
42  /** True iff we have published our consensus. */
43  int have_published_consensus;
44 
45  /* True iff this voting schedule was set on demand meaning not through the
46  * normal vote operation of a dirauth or when a consensus is set. This only
47  * applies to a directory authority that needs to recalculate the voting
48  * timings only for the first vote even though this object was initialized
49  * prior to voting. */
50  int created_on_demand;
51 
52  /** The valid-after time of the last live consensus that filled this voting
53  * schedule. It's used to detect outdated voting schedules. */
54  time_t live_consensus_valid_after;
55 } voting_schedule_t;
56 
57 /* Public API. */
58 
59 extern voting_schedule_t voting_schedule;
60 
62  time_t now);
63 
67 
68 #else /* !defined(HAVE_MODULE_DIRAUTH) */
69 
70 #define dirauth_sched_recalculate_timing(opt,now) \
71  ((void)(opt), (void)(now))
72 
73 static inline time_t
75 {
76  tor_assert_unreached();
77  return 0;
78 }
79 static inline time_t
81 {
82  tor_assert_unreached();
83  return 0;
84 }
85 static inline int
87 {
88  tor_assert_unreached();
89  return 1;
90 }
91 #endif /* defined(HAVE_MODULE_DIRAUTH) */
92 
93 #endif /* !defined(TOR_VOTING_SCHEDULE_H) */
Master header file for Tor-specific functionality.
void dirauth_sched_recalculate_timing(const or_options_t *options, time_t now)
int dirauth_sched_get_configured_interval(void)
time_t dirauth_sched_get_cur_valid_after_time(void)
time_t dirauth_sched_get_next_valid_after_time(void)