diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-05-14 19:43:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-05-15 17:21:55 -0400 |
commit | dcc533fb133646d81c2fa6632d6fb7f05f99f650 (patch) | |
tree | 8cdeaf5d253314f59dc00cc1f9e86892b095e9eb /src/or/networkstatus.c | |
parent | 2f06345db3b6f85144c1d8a0b6ca55e2b1e243ce (diff) | |
download | tor-dcc533fb133646d81c2fa6632d6fb7f05f99f650.tar.gz tor-dcc533fb133646d81c2fa6632d6fb7f05f99f650.zip |
Implement functions to expose valid/fresh-until and voters
These still won't do anything till I get the values to be filled in.
Also, I changed the API a little (with corresponding changes in
directory.c) to match things that it's easier to store.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index bd106fd9a6..fffd1078be 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1407,16 +1407,24 @@ networkstatus_get_live_consensus,(time_t now)) * Return 1 if the consensus is reasonably live, or 0 if it is too old. */ int -networkstatus_consensus_reasonably_live(networkstatus_t *consensus, time_t now) +networkstatus_consensus_reasonably_live(const networkstatus_t *consensus, + time_t now) { -#define REASONABLY_LIVE_TIME (24*60*60) if (BUG(!consensus)) return 0; - if (now <= consensus->valid_until + REASONABLY_LIVE_TIME) - return 1; + return networkstatus_valid_until_is_reasonably_live(consensus->valid_until, + now); +} - return 0; +/** As networkstatus_consensus_reasonably_live, but takes a valid_until + * time rather than an entire consensus. */ +int +networkstatus_valid_until_is_reasonably_live(time_t valid_until, + time_t now) +{ +#define REASONABLY_LIVE_TIME (24*60*60) + return (now <= valid_until + REASONABLY_LIVE_TIME); } /* XXXX remove this in favor of get_live_consensus. But actually, |