diff options
author | Linus Nordberg <linus@torproject.org> | 2013-06-05 15:48:57 +0200 |
---|---|---|
committer | Linus Nordberg <linus@torproject.org> | 2013-06-08 15:25:32 +0200 |
commit | 4d54b9774d11f47c6a670ab9b380e027a524f5f9 (patch) | |
tree | 6256b3849c531a7ff05914e6055f24b6befdbc06 /src/or/dirvote.c | |
parent | bcdc0022693c75ea1523468e783bf03832e0a358 (diff) | |
download | tor-4d54b9774d11f47c6a670ab9b380e027a524f5f9.tar.gz tor-4d54b9774d11f47c6a670ab9b380e027a524f5f9.zip |
Add support for offsetting the voting interval in order to bootstrap faster.
A new option TestingV3AuthVotingStartOffset is added which offsets the
starting time of the voting interval. This is possible only when
TestingTorNetwork is set.
This patch makes run_scheduled_events() check for new consensus
downloads every second when TestingTorNetwork, instead of every
minute. This should be fine, see #8532 for reasoning.
This patch also brings MIN_VOTE_SECONDS and MIN_DIST_SECONDS down from
20 to 2 seconds, unconditionally. This makes sanity checking of
misconfiguration slightly less sane.
Addresses #8532.
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 0c386e604e..4f0ab6833e 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -2523,12 +2523,13 @@ dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out) timing_out->dist_delay = options->V3AuthDistDelay; } -/** Return the start of the next interval of size <b>interval</b> (in seconds) - * after <b>now</b>. Midnight always starts a fresh interval, and if the last - * interval of a day would be truncated to less than half its size, it is - * rolled into the previous interval. */ +/** Return the start of the next interval of size <b>interval</b> (in + * seconds) after <b>now</b>, plus <b>offset</b>. Midnight always + * starts a fresh interval, and if the last interval of a day would be + * truncated to less than half its size, it is rolled into the + * previous interval. */ time_t -dirvote_get_start_of_next_interval(time_t now, int interval) +dirvote_get_start_of_next_interval(time_t now, int interval, int offset) { struct tm tm; time_t midnight_today=0; @@ -2556,6 +2557,10 @@ dirvote_get_start_of_next_interval(time_t now, int interval) if (next + interval/2 > midnight_tomorrow) next = midnight_tomorrow; + next += offset; + if (next - interval > now) + next -= interval; + return next; } @@ -2619,8 +2624,10 @@ dirvote_recalculate_timing(const or_options_t *options, time_t now) vote_delay = dist_delay = interval / 4; start = voting_schedule.interval_starts = - dirvote_get_start_of_next_interval(now,interval); - end = dirvote_get_start_of_next_interval(start+1, interval); + dirvote_get_start_of_next_interval(now,interval, + options->TestingV3AuthVotingStartOffset); + end = dirvote_get_start_of_next_interval(start+1, interval, + options->TestingV3AuthVotingStartOffset); tor_assert(end > start); |