25 static voting_schedule_t *
26 create_voting_schedule(
const or_options_t *options, time_t now,
int severity)
28 int interval, vote_delay, dist_delay;
32 voting_schedule_t *new_voting_schedule;
34 new_voting_schedule = tor_malloc_zero(
sizeof(voting_schedule_t));
45 new_voting_schedule->live_consensus_valid_after = consensus->
valid_after;
53 new_voting_schedule->interval = interval;
55 if (vote_delay + dist_delay > interval/2)
56 vote_delay = dist_delay = interval / 4;
58 start = new_voting_schedule->interval_starts =
66 new_voting_schedule->fetch_missing_signatures = start - (dist_delay/2);
67 new_voting_schedule->voting_ends = start - dist_delay;
68 new_voting_schedule->fetch_missing_votes =
69 start - dist_delay - (vote_delay/2);
70 new_voting_schedule->voting_starts = start - dist_delay - vote_delay;
73 char tbuf[ISO_TIME_LEN+1];
75 tor_log(severity,
LD_DIR,
"Choosing expected valid-after time as %s: "
76 "consensus_set=%d, interval=%d",
77 tbuf, consensus?1:0, interval);
80 return new_voting_schedule;
83 #define voting_schedule_free(s) \
84 FREE_AND_NULL(voting_schedule_t, voting_schedule_free_, (s))
91 if (!voting_schedule_to_free)
96 voting_schedule_t voting_schedule;
103 static const voting_schedule_t *
107 bool need_to_recalculate_voting_schedule =
false;
113 sizeof(voting_schedule))) {
114 need_to_recalculate_voting_schedule =
true;
121 if (ns && ns->
valid_after != voting_schedule.live_consensus_valid_after) {
122 log_info(
LD_DIR,
"Voting schedule is outdated: recalculating (%d/%d)",
124 (
int) voting_schedule.live_consensus_valid_after);
125 need_to_recalculate_voting_schedule =
true;
129 if (need_to_recalculate_voting_schedule) {
131 voting_schedule.created_on_demand = 1;
134 return &voting_schedule;
156 time_t next_start = sched->interval_starts;
157 int interval = sched->interval;
179 voting_schedule_t *new_voting_schedule;
182 new_voting_schedule = create_voting_schedule(options, now,
LOG_INFO);
186 memcpy(&voting_schedule, new_voting_schedule,
sizeof(voting_schedule));
187 voting_schedule_free(new_voting_schedule);
const or_options_t * get_options(void)
Header file for config.c.
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
time_t voting_sched_get_start_of_interval_after(time_t now, int interval, int offset)
networkstatus_t * networkstatus_get_live_consensus(time_t now)
Header file for networkstatus.c.
Networkstatus consensus/vote structure.
Master header file for Tor-specific functionality.
int TestingV3AuthInitialDistDelay
int TestingV3AuthInitialVotingInterval
int TestingV3AuthInitialVoteDelay
int TestingV3AuthVotingStartOffset
void format_iso_time(char *buf, time_t t)
int fast_mem_is_zero(const char *mem, size_t len)
static void voting_schedule_free_(voting_schedule_t *voting_schedule_to_free)
static const voting_schedule_t * dirauth_get_voting_schedule(void)
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)
Header file for voting_schedule.c.