diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-05-13 01:03:55 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2017-05-13 01:05:15 +0200 |
commit | 363f4b8db5f9f642f848f2e50ae0c6bb0f1ff25e (patch) | |
tree | 3a005875296b623b8fc120df1f960e00e877d6e1 /src | |
parent | 64116ab97f14592ed67899512e8e3279df898adc (diff) | |
download | tor-363f4b8db5f9f642f848f2e50ae0c6bb0f1ff25e.tar.gz tor-363f4b8db5f9f642f848f2e50ae0c6bb0f1ff25e.zip |
Add stub functions for querying metadata about the consensus.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/conscache.c | 59 | ||||
-rw-r--r-- | src/or/conscache.h | 8 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c index 5ffa129bbe..fd46cbe65e 100644 --- a/src/or/conscache.c +++ b/src/or/conscache.c @@ -374,6 +374,65 @@ consensus_cache_entry_get_body(const consensus_cache_entry_t *ent, return 0; } +/** Read the lifetime of cached object <b>ent</b> into <b>lifetime</b>. */ +int consensus_cache_entry_get_lifetime(const consensus_cache_entry_t *ent, + long *lifetime) +{ + if (BUG(ent->magic != CCE_MAGIC)) + return -1; // LCOV_EXCL_LINE + + tor_assert(lifetime); + + // FIXME(ahf): Fill out. + *lifetime = 0; + + return 0; +} + +/** Return non-zero if the cache object found in <b>ent</b> is + * reasonably live, otherwise return 0. Use <b>now</b> to pass the + * timestamp used for comparison. */ +int consensus_cache_entry_is_reasonably_live(const consensus_cache_entry_t *ent, + time_t now) +{ + if (BUG(ent->magic != CCE_MAGIC)) + return -1; // LCOV_EXCL_LINE + + // FIXME(ahf): Fill out. + (void)now; + + return 1; +} + +/** Read the set of voters from the cached object <b>ent</b> into <b>out</b>. */ +int consensus_cache_entry_get_voters(const consensus_cache_entry_t *ent, + smartlist_t *out) +{ + if (BUG(ent->magic != CCE_MAGIC)) + return -1; // LCOV_EXCL_LINE + + // FIXME(ahf): Fill out. + (void)out; + + return 0; +} + +/** Read the valid until timestamp from the cached object <b>ent</b> + * into <b>out</b>. */ +int consensus_cache_entry_valid_until(const consensus_cache_entry_t *ent, + time_t *out) +{ + if (BUG(ent->magic != CCE_MAGIC)) + return -1; // LCOV_EXCL_LINE + + tor_assert(out); + + // FIXME(ahf): Fill out. + *out = time(NULL); + + return 0; +} + /** * Unmap every mmap'd element of <b>cache</b> that has been unused * since <b>cutoff</b>. diff --git a/src/or/conscache.h b/src/or/conscache.h index aef54201f0..fcc3f3e330 100644 --- a/src/or/conscache.h +++ b/src/or/conscache.h @@ -52,6 +52,14 @@ void consensus_cache_entry_mark_for_aggressive_release( int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent, const uint8_t **body_out, size_t *sz_out); +int consensus_cache_entry_get_lifetime(const consensus_cache_entry_t *ent, + long *lifetime); +int consensus_cache_entry_is_reasonably_live(const consensus_cache_entry_t *ent, + time_t now); +int consensus_cache_entry_get_voters(const consensus_cache_entry_t *ent, + smartlist_t *out); +int consensus_cache_entry_valid_until(const consensus_cache_entry_t *ent, + time_t *out); #ifdef TOR_UNIT_TESTS int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent); |