#include "statefile.h"
#include "transports.h"
#include "ext_orport.h"
+#include "voting_schedule.h"
#ifdef _WIN32
#include <shlobj.h>
#endif
/* We may need to reschedule some directory stuff if our status changed. */
if (old_options) {
if (options_transition_affects_dirauth_timing(old_options, options)) {
- dirvote_recalculate_timing(options, time(NULL));
+ voting_schedule_recalculate_timing(options, time(NULL));
reschedule_dirvote(options);
}
if (!bool_eq(directory_fetches_dir_info_early(options),
"Mine is %s.",
keys, hex_str(c->cache_info.identity_digest, DIGEST_LEN));
tor_free(keys);
- dirvote_recalculate_timing(options, now);
+ voting_schedule_recalculate_timing(options, now);
}
#define IF_TIME_FOR_NEXT_ACTION(when_field, done_field) \
networkstatus_get_latest_consensus_by_flavor(FLAV_NS));
/* XXXX We will want to try again later if we haven't got enough
* signatures yet. Implement this if it turns out to ever happen. */
- dirvote_recalculate_timing(options, now);
+ voting_schedule_recalculate_timing(options, now);
return voting_schedule.voting_starts;
} ENDIF
#endif /* HAVE_MODULE_DIRAUTH */
-void dirvote_recalculate_timing(const or_options_t *options, time_t now);
/* Item access */
MOCK_DECL(const char*, dirvote_get_pending_consensus,
(consensus_flavor_t flav));
#include "transports.h"
#include "torcert.h"
#include "channelpadding.h"
+#include "voting_schedule.h"
#include "dirauth/dirvote.h"
* the first thing we need to do is recalculate the voting schedule static
* object so we can use the timings in there needed by some subsystems
* such as hidden service and shared random. */
- dirvote_recalculate_timing(options, now);
+ voting_schedule_recalculate_timing(options, now);
reschedule_dirvote(options);
nodelist_set_consensus(c);
#include "config.h"
#include "networkstatus.h"
-#include "dirauth/dirvote.h"
-
/* =====
* Vote scheduling
* ===== */
* voting schedule can lead to bugs. */
if (tor_mem_is_zero((const char *) &voting_schedule,
sizeof(voting_schedule))) {
- dirvote_recalculate_timing(get_options(), time(NULL));
+ voting_schedule_recalculate_timing(get_options(), time(NULL));
voting_schedule.created_on_demand = 1;
}
return voting_schedule.interval_starts;
* doing. All type of tor do that because HS subsystem needs the timing as
* well to function properly. */
void
-dirvote_recalculate_timing(const or_options_t *options, time_t now)
+voting_schedule_recalculate_timing(const or_options_t *options, time_t now)
{
voting_schedule_t *new_voting_schedule;
extern voting_schedule_t voting_schedule;
+void voting_schedule_recalculate_timing(const or_options_t *options,
+ time_t now);
+
time_t voting_schedule_get_start_of_next_interval(time_t now,
int interval,
int offset);
#include "torcert.h"
#include "relay.h"
#include "log_test_helpers.h"
+#include "voting_schedule.h"
#define NS_MODULE dir
sign_skey_2 = crypto_pk_new();
sign_skey_3 = crypto_pk_new();
sign_skey_leg1 = pk_generate(4);
- dirvote_recalculate_timing(get_options(), now);
+ voting_schedule_recalculate_timing(get_options(), now);
sr_state_init(0, 0);
tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
#include "dirserv.h"
#include "dirauth/dirvote.h"
#include "log_test_helpers.h"
+#include "voting_schedule.h"
#ifdef _WIN32
/* For mkdir() */
mock_options->TestingV3AuthInitialDistDelay = 1;
time_t now = 1441223455 -1;
- dirvote_recalculate_timing(mock_options, now);
+ voting_schedule_recalculate_timing(mock_options, now);
const char *msg_out = NULL;
int status_out = 0;
mock_options->TestingV3AuthInitialDistDelay = 1;
time_t now = 1441223455 -1;
- dirvote_recalculate_timing(mock_options, now);
+ voting_schedule_recalculate_timing(mock_options, now);
struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, &msg_out,
&status_out);
mock_options->TestingV3AuthInitialDistDelay = 1;
time_t now = 1441223455;
- dirvote_recalculate_timing(mock_options, now-1);
+ voting_schedule_recalculate_timing(mock_options, now-1);
struct pending_vote_t *vote = dirvote_add_vote(VOTE_BODY_V3, &msg_out,
&status_out);
#include "circuitlist.h"
#include "dirauth/shared_random.h"
#include "util.h"
+#include "voting_schedule.h"
/** Test the validation of HS v3 addresses */
static void
tt_int_op(ret, OP_EQ, 0);
ret = parse_rfc1123_time("Sat, 26 Oct 1985 01:00:00 UTC", &ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns.valid_after);
ret = hs_in_period_between_tp_and_srv(&ns, 0);
tt_int_op(ret, OP_EQ, 0);
tt_int_op(ret, OP_EQ, 0);
ret = parse_rfc1123_time("Sat, 26 Oct 1985 12:00:00 UTC", &ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns.valid_after);
ret = hs_in_period_between_tp_and_srv(&ns, 0);
tt_int_op(ret, OP_EQ, 0);
tt_int_op(ret, OP_EQ, 0);
ret = parse_rfc1123_time("Sat, 26 Oct 1985 13:00:00 UTC", &ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns.valid_after);
ret = hs_in_period_between_tp_and_srv(&ns, 0);
tt_int_op(ret, OP_EQ, 1);
tt_int_op(ret, OP_EQ, 0);
ret = parse_rfc1123_time("Sat, 27 Oct 1985 00:00:00 UTC", &ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns.valid_after);
ret = hs_in_period_between_tp_and_srv(&ns, 0);
tt_int_op(ret, OP_EQ, 1);
tt_int_op(ret, OP_EQ, 0);
ret = parse_rfc1123_time("Sat, 27 Oct 1985 01:00:00 UTC", &ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns.valid_after);
ret = hs_in_period_between_tp_and_srv(&ns, 0);
tt_int_op(ret, OP_EQ, 0);
&mock_service_ns->valid_until);
set_consensus_times(cfg->service_valid_until,
&mock_service_ns->fresh_until);
- dirvote_recalculate_timing(get_options(), mock_service_ns->valid_after);
+ voting_schedule_recalculate_timing(get_options(),
+ mock_service_ns->valid_after);
/* Set client consensus time. */
set_consensus_times(cfg->client_valid_after,
&mock_client_ns->valid_after);
&mock_client_ns->valid_until);
set_consensus_times(cfg->client_valid_until,
&mock_client_ns->fresh_until);
- dirvote_recalculate_timing(get_options(), mock_client_ns->valid_after);
+ voting_schedule_recalculate_timing(get_options(),
+ mock_client_ns->valid_after);
/* New time period checks for this scenario. */
tt_int_op(hs_in_period_between_tp_and_srv(mock_service_ns, 0), OP_EQ,
} else {
tt_assert(0);
}
- dirvote_recalculate_timing(get_options(), ns->valid_after);
+ voting_schedule_recalculate_timing(get_options(), ns->valid_after);
/* Set system time: pretend to be just 2 minutes before consensus expiry */
real_time = ns->valid_until - 120;
#include "rendservice.h"
#include "statefile.h"
#include "dirauth/shared_random_state.h"
+#include "voting_schedule.h"
/* Trunnel */
#include "hs/cell_establish_intro.h"
ret = parse_rfc1123_time("Sat, 26 Oct 1985 14:00:00 UTC",
&mock_ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), mock_ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), mock_ns.valid_after);
/* Create a service with a default descriptor and state. It's added to the
* global map. */
ret = parse_rfc1123_time("Sat, 27 Oct 1985 02:00:00 UTC",
&mock_ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), mock_ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), mock_ns.valid_after);
/* Note down what to expect for the next rotation time which is 01:00 + 23h
* meaning 00:00:00. */
ret = parse_rfc1123_time("Sat, 26 Oct 1985 04:00:00 UTC",
&mock_ns.fresh_until);
tt_int_op(ret, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), mock_ns.valid_after);
+ voting_schedule_recalculate_timing(get_options(), mock_ns.valid_after);
/* Create a service without a current descriptor to trigger a build. */
service = helper_create_service();
#include "shared_random_common.h"
#include "networkstatus.h"
#include "log_test_helpers.h"
+#include "voting_schedule.h"
static authority_cert_t *mock_cert;
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
valid_until_time = get_state_valid_until_time(current_time);
/* Compare it with the correct result */
retval = parse_rfc1123_time("Mon, 20 Apr 2015 19:22:00 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:00 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:59 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:15:32 UTC",
¤t_time);
tt_int_op(retval, OP_EQ, 0);
- dirvote_recalculate_timing(get_options(), current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
tt_int_op(retval, OP_EQ, 0);
time_t now = mock_consensus.valid_after;
- dirvote_recalculate_timing(get_options(), now);
+ voting_schedule_recalculate_timing(get_options(), now);
time_t start_time_of_protocol_run =
sr_state_get_start_time_of_current_protocol_run(now);
tt_assert(start_time_of_protocol_run);