diff options
author | David Goulet <dgoulet@torproject.org> | 2018-04-25 09:06:29 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-04-27 11:40:44 -0400 |
commit | 26817d9d2231d2580361ae9082db17250b454628 (patch) | |
tree | 970d471733f42a1c035a96be15d5da2e29c891b8 /src/or/dirvote_common.h | |
parent | 79a1112a495f76542d13eab4992ff4fd50f7f830 (diff) | |
download | tor-26817d9d2231d2580361ae9082db17250b454628.tar.gz tor-26817d9d2231d2580361ae9082db17250b454628.zip |
dirvote: Extract shared functions to common file
No code behavior change.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/dirvote_common.h')
-rw-r--r-- | src/or/dirvote_common.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/or/dirvote_common.h b/src/or/dirvote_common.h new file mode 100644 index 0000000000..91d32aaa84 --- /dev/null +++ b/src/or/dirvote_common.h @@ -0,0 +1,69 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file dirvote_common.h + * \brief Header file for dirvote_common.c. + **/ + +#ifndef TOR_DIRVOTE_COMMON_H +#define TOR_DIRVOTE_COMMON_H + +#include "or.h" + +/* Dirauth module. */ +#include "dirauth/dirvote.h" + +/** Scheduling information for a voting interval. */ +typedef struct { + /** When do we generate and distribute our vote for this interval? */ + time_t voting_starts; + /** When do we send an HTTP request for any votes that we haven't + * been posted yet?*/ + time_t fetch_missing_votes; + /** When do we give up on getting more votes and generate a consensus? */ + time_t voting_ends; + /** When do we send an HTTP request for any signatures we're expecting to + * see on the consensus? */ + time_t fetch_missing_signatures; + /** When do we publish the consensus? */ + time_t interval_starts; + + /* True iff we have generated and distributed our vote. */ + int have_voted; + /* True iff we've requested missing votes. */ + int have_fetched_missing_votes; + /* True iff we have built a consensus and sent the signatures around. */ + int have_built_consensus; + /* True iff we've fetched missing signatures. */ + int have_fetched_missing_signatures; + /* True iff we have published our consensus. */ + int have_published_consensus; + + /* True iff this voting schedule was set on demand meaning not through the + * normal vote operation of a dirauth or when a consensus is set. This only + * applies to a directory authority that needs to recalculate the voting + * timings only for the first vote even though this object was initilized + * prior to voting. */ + int created_on_demand; +} voting_schedule_t; + +/* Public API. */ + +extern voting_schedule_t voting_schedule; + +void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out); +time_t dirvote_get_start_of_next_interval(time_t now, + int interval, + int offset); +time_t dirvote_get_next_valid_after_time(void); + +document_signature_t *voter_get_sig_by_algorithm( + const networkstatus_voter_info_t *voter, + digest_algorithm_t alg); + +/* Cert manipulation */ +authority_cert_t *authority_cert_dup(authority_cert_t *cert); + +#endif /* TOR_DIRVOTE_COMMON_H */ + |