diff options
Diffstat (limited to 'src/feature/dirauth')
-rw-r--r-- | src/feature/dirauth/shared_random_state.c | 2 | ||||
-rw-r--r-- | src/feature/dirauth/voting_schedule.c | 19 | ||||
-rw-r--r-- | src/feature/dirauth/voting_schedule.h | 4 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c index 305c2cc94c..c15f8c9937 100644 --- a/src/feature/dirauth/shared_random_state.c +++ b/src/feature/dirauth/shared_random_state.c @@ -139,7 +139,7 @@ get_state_valid_until_time(time_t now) voting_interval = get_voting_interval(); /* Find the time the current round started. */ - beginning_of_current_round = get_start_time_of_current_round(); + beginning_of_current_round = dirauth_sched_get_cur_valid_after_time(); /* Find how many rounds are left till the end of the protocol run */ current_round = (now / voting_interval) % total_rounds; diff --git a/src/feature/dirauth/voting_schedule.c b/src/feature/dirauth/voting_schedule.c index 5e076a0ef5..ddb2c4bb07 100644 --- a/src/feature/dirauth/voting_schedule.c +++ b/src/feature/dirauth/voting_schedule.c @@ -51,6 +51,7 @@ create_voting_schedule(const or_options_t *options, time_t now, int severity) } tor_assert(interval > 0); + new_voting_schedule->interval = interval; if (vote_delay + dist_delay > interval/2) vote_delay = dist_delay = interval / 4; @@ -143,6 +144,24 @@ dirauth_sched_get_next_valid_after_time(void) return dirauth_get_voting_schedule()->interval_starts; } +/** + * Return our best idea of what the valid-after time for the _current_ + * consensus, whether we have one or not. + * + * Dirauth only. + **/ +time_t +dirauth_sched_get_cur_valid_after_time(void) +{ + const voting_schedule_t *sched = dirauth_get_voting_schedule(); + time_t next_start = sched->interval_starts; + int interval = sched->interval; + int offset = get_options()->TestingV3AuthVotingStartOffset; + return voting_sched_get_start_of_interval_after(next_start - interval - 1, + interval, + offset); +} + /** Return the voting interval that we are configured to use. * * Dirauth only. */ diff --git a/src/feature/dirauth/voting_schedule.h b/src/feature/dirauth/voting_schedule.h index b5dc811bfc..5472719b25 100644 --- a/src/feature/dirauth/voting_schedule.h +++ b/src/feature/dirauth/voting_schedule.h @@ -26,6 +26,9 @@ typedef struct { /** When do we publish the consensus? */ time_t interval_starts; + /** Our computed dirauth interval */ + int interval; + /** True iff we have generated and distributed our vote. */ int have_voted; /** True iff we've requested missing votes. */ @@ -57,6 +60,7 @@ void dirauth_sched_recalculate_timing(const or_options_t *options, time_t now); time_t dirauth_sched_get_next_valid_after_time(void); +time_t dirauth_sched_get_cur_valid_after_time(void); int dirauth_sched_get_configured_interval(void); #endif /* !defined(TOR_VOTING_SCHEDULE_H) */ |