diff options
author | Andrea Shepard <andrea@torproject.org> | 2016-06-27 16:38:37 +0000 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2016-06-27 16:38:37 +0000 |
commit | 8cf9fe5ba63c1c2b711d852b61e734c48cf482b5 (patch) | |
tree | 4bbbb2ae37698f0f9ef07a6a4e03f8c38538e29e /src/or/networkstatus.c | |
parent | 703254a8321788bd6d03ec5f335fe338916fef6f (diff) | |
download | tor-8cf9fe5ba63c1c2b711d852b61e734c48cf482b5.tar.gz tor-8cf9fe5ba63c1c2b711d852b61e734c48cf482b5.zip |
Expose consensus download statuses on the control port
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 3471288969..45688b18f6 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1179,6 +1179,52 @@ consensus_is_waiting_for_certs(void) ? 1 : 0; } +/** Look up the currently active (depending on bootstrap status) download + * status for this consensus flavor and return a pointer to it. + */ +download_status_t * +networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor) +{ + download_status_t *dl = NULL; + const int we_are_bootstrapping = + networkstatus_consensus_is_bootstrapping(time(NULL)); + + if (flavor <= N_CONSENSUS_FLAVORS) { + dl = &((we_are_bootstrapping ? + consensus_bootstrap_dl_status : consensus_dl_status)[flavor]); + } + + return dl; +} + +/** Look up the bootstrap download status for this consensus flavor + * and return a pointer to it. */ +download_status_t * +networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor) +{ + download_status_t *dl = NULL; + + if (flavor <= N_CONSENSUS_FLAVORS) { + dl = &(consensus_bootstrap_dl_status[flavor]); + } + + return dl; +} + +/** Look up the running (non-bootstrap) download status for this consensus + * flavor and return a pointer to it. */ +download_status_t * +networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor) +{ + download_status_t *dl = NULL; + + if (flavor <= N_CONSENSUS_FLAVORS) { + dl = &(consensus_dl_status[flavor]); + } + + return dl; +} + /** Return the most recent consensus that we have downloaded, or NULL if we * don't have one. */ networkstatus_t * |