aboutsummaryrefslogtreecommitdiff
path: root/src/feature/hs_common/shared_random_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/feature/hs_common/shared_random_client.c')
-rw-r--r--src/feature/hs_common/shared_random_client.c23
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 {