diff options
author | David Goulet <dgoulet@torproject.org> | 2017-10-27 09:13:43 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-10-27 09:23:18 -0400 |
commit | 60164f057c4ac5471754f0326ab631448cd7c120 (patch) | |
tree | 53d0e25980fbb08cc34652f6d279948727664608 /src/or/dirvote.c | |
parent | e598c6f6dee3696df1d0c228268a1bf1b369eb86 (diff) | |
download | tor-60164f057c4ac5471754f0326ab631448cd7c120.tar.gz tor-60164f057c4ac5471754f0326ab631448cd7c120.zip |
dirvote: Move code. No behavior change
Needed for next commit to address #23623.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index ba0ab7a776..ddaadb3871 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -2787,44 +2787,6 @@ dirvote_get_start_of_next_interval(time_t now, int interval, int offset) return next; } -/* Using the time <b>now</b>, return the next voting valid-after time. */ -time_t -get_next_valid_after_time(time_t now) -{ - time_t next_valid_after_time; - const or_options_t *options = get_options(); - voting_schedule_t *new_voting_schedule = - get_voting_schedule(options, now, LOG_INFO); - tor_assert(new_voting_schedule); - - next_valid_after_time = new_voting_schedule->interval_starts; - voting_schedule_free(new_voting_schedule); - - return next_valid_after_time; -} - -static voting_schedule_t voting_schedule; - -/** Set voting_schedule to hold the timing for the next vote we should be - * doing. */ -void -dirvote_recalculate_timing(const or_options_t *options, time_t now) -{ - voting_schedule_t *new_voting_schedule; - - if (!authdir_mode_v3(options)) { - return; - } - - /* get the new voting schedule */ - new_voting_schedule = get_voting_schedule(options, now, LOG_NOTICE); - tor_assert(new_voting_schedule); - - /* Fill in the global static struct now */ - memcpy(&voting_schedule, new_voting_schedule, sizeof(voting_schedule)); - voting_schedule_free(new_voting_schedule); -} - /* Populate and return a new voting_schedule_t that can be used to schedule * voting. The object is allocated on the heap and it's the responsibility of * the caller to free it. Can't fail. */ @@ -2891,6 +2853,44 @@ voting_schedule_free(voting_schedule_t *voting_schedule_to_free) tor_free(voting_schedule_to_free); } +static voting_schedule_t voting_schedule; + +/* Using the time <b>now</b>, return the next voting valid-after time. */ +time_t +get_next_valid_after_time(time_t now) +{ + time_t next_valid_after_time; + const or_options_t *options = get_options(); + voting_schedule_t *new_voting_schedule = + get_voting_schedule(options, now, LOG_INFO); + tor_assert(new_voting_schedule); + + next_valid_after_time = new_voting_schedule->interval_starts; + voting_schedule_free(new_voting_schedule); + + return next_valid_after_time; +} + +/** Set voting_schedule to hold the timing for the next vote we should be + * doing. */ +void +dirvote_recalculate_timing(const or_options_t *options, time_t now) +{ + voting_schedule_t *new_voting_schedule; + + if (!authdir_mode_v3(options)) { + return; + } + + /* get the new voting schedule */ + new_voting_schedule = get_voting_schedule(options, now, LOG_NOTICE); + tor_assert(new_voting_schedule); + + /* Fill in the global static struct now */ + memcpy(&voting_schedule, new_voting_schedule, sizeof(voting_schedule)); + voting_schedule_free(new_voting_schedule); +} + /** Entry point: Take whatever voting actions are pending as of <b>now</b>. */ void dirvote_act(const or_options_t *options, time_t now) |