diff options
author | David Goulet <dgoulet@torproject.org> | 2021-01-12 10:46:25 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-01-12 10:46:25 -0500 |
commit | 60da5d62225c975842ef57195b7243baa7033acb (patch) | |
tree | c355fe467bd86c209bc6f75c6eb5fec367fb0568 /src/feature/hs_common | |
parent | 4b39f46a611ff48ceb7ea212dbcdb2e5b6d26d3b (diff) | |
parent | 04b0263974c7ad1327e7a193884cf31d55f7949a (diff) | |
download | tor-60da5d62225c975842ef57195b7243baa7033acb.tar.gz tor-60da5d62225c975842ef57195b7243baa7033acb.zip |
Merge branch 'ticket40237_035_01' into ticket40237_043_01
Diffstat (limited to 'src/feature/hs_common')
-rw-r--r-- | src/feature/hs_common/shared_random_client.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/feature/hs_common/shared_random_client.c b/src/feature/hs_common/shared_random_client.c index d6c1d8f155..b4b2f2c9d3 100644 --- a/src/feature/hs_common/shared_random_client.c +++ b/src/feature/hs_common/shared_random_client.c @@ -12,6 +12,7 @@ #include "app/config/config.h" #include "feature/dircommon/voting_schedule.h" +#include "feature/nodelist/microdesc.h" #include "feature/nodelist/networkstatus.h" #include "lib/encoding/binascii.h" @@ -36,7 +37,9 @@ int get_voting_interval(void) { int interval; - networkstatus_t *consensus = networkstatus_get_live_consensus(time(NULL)); + networkstatus_t *consensus = + networkstatus_get_reasonably_live_consensus(time(NULL), + usable_consensus_flavor()); if (consensus) { interval = (int)(consensus->fresh_until - consensus->valid_after); @@ -141,7 +144,8 @@ sr_get_current(const networkstatus_t *ns) if (ns) { consensus = ns; } else { - consensus = networkstatus_get_live_consensus(approx_time()); + consensus = networkstatus_get_reasonably_live_consensus(approx_time(), + usable_consensus_flavor()); } /* Ideally we would never be asked for an SRV without a live consensus. Make * sure this assumption is correct. */ @@ -164,7 +168,8 @@ sr_get_previous(const networkstatus_t *ns) if (ns) { consensus = ns; } else { - consensus = networkstatus_get_live_consensus(approx_time()); + consensus = networkstatus_get_reasonably_live_consensus(approx_time(), + usable_consensus_flavor()); } /* Ideally we would never be asked for an SRV without a live consensus. Make * sure this assumption is correct. */ @@ -236,10 +241,14 @@ sr_state_get_start_time_of_current_protocol_run(void) int voting_interval = get_voting_interval(); time_t beginning_of_curr_round; - /* This function is not used for voting purposes, so if we have a live - consensus, use its valid-after as the beginning of the current round, - otherwise resort to the voting schedule which should always exist. */ - networkstatus_t *ns = networkstatus_get_live_consensus(approx_time()); + /* This function is not used for voting purposes, so if we have a reasonably + * live consensus, use its valid-after as the beginning of the current + * round. If we have no consensus but we're an authority, use our own + * schedule. Otherwise, try using our view of the voting interval to figure + * out when the current round _should_ be starting. */ + networkstatus_t *ns = + networkstatus_get_reasonably_live_consensus(approx_time(), + usable_consensus_flavor()); if (ns) { beginning_of_curr_round = ns->valid_after; } else { |