diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-05-11 17:20:33 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-27 18:04:44 -0400 |
commit | 3a492d31d5c50ef3b766881ae1d765c296d55797 (patch) | |
tree | c4ae30aa130eb1ed56c38cae719d15dc4f09e7b2 /src/or/networkstatus.c | |
parent | e34d0d3365f5263d2888d63a4d58dc479f191565 (diff) | |
download | tor-3a492d31d5c50ef3b766881ae1d765c296d55797.tar.gz tor-3a492d31d5c50ef3b766881ae1d765c296d55797.zip |
Download microdescriptors if you're a cache
This commit adds some functions to see what microdescriptors we're missing,
and adds fetch-microdesc/store-microdesc logic to the directory code.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 4ccd1aed4d..704e665253 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -978,21 +978,25 @@ networkstatus_get_v2_list(void) } /** Return the consensus view of the status of the router whose current - * <i>descriptor</i> digest is <b>digest</b>, or NULL if no such router is - * known. */ + * <i>descriptor</i> digest in <b>consensus</b> is <b>digest</b>, or NULL if + * no such router is known. */ routerstatus_t * -router_get_consensus_status_by_descriptor_digest(const char *digest) +router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus, + const char *digest) { - if (!current_consensus) return NULL; - if (!current_consensus->desc_digest_map) { - digestmap_t * m = current_consensus->desc_digest_map = digestmap_new(); - SMARTLIST_FOREACH(current_consensus->routerstatus_list, + if (!consensus) + consensus = current_consensus; + if (!consensus) + return NULL; + if (!consensus->desc_digest_map) { + digestmap_t *m = consensus->desc_digest_map = digestmap_new(); + SMARTLIST_FOREACH(consensus->routerstatus_list, routerstatus_t *, rs, { digestmap_set(m, rs->descriptor_digest, rs); }); } - return digestmap_get(current_consensus->desc_digest_map, digest); + return digestmap_get(consensus->desc_digest_map, digest); } /** Given the digest of a router descriptor, return its current download @@ -1001,7 +1005,10 @@ download_status_t * router_get_dl_status_by_descriptor_digest(const char *d) { routerstatus_t *rs; - if ((rs = router_get_consensus_status_by_descriptor_digest(d))) + if (!current_ns_consensus) + return NULL; + if ((rs = router_get_consensus_status_by_descriptor_digest( + current_ns_consensus, d))) return &rs->dl_status; if (v2_download_status_map) return digestmap_get(v2_download_status_map, d); @@ -2118,7 +2125,7 @@ signed_descs_update_status_from_consensus_networkstatus(smartlist_t *descs) char dummy[DIGEST_LEN]; /* instantiates the digest map. */ memset(dummy, 0, sizeof(dummy)); - router_get_consensus_status_by_descriptor_digest(dummy); + router_get_consensus_status_by_descriptor_digest(ns, dummy); } SMARTLIST_FOREACH(descs, signed_descriptor_t *, d, { |