diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-10-31 11:32:32 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-10-31 11:32:32 -0400 |
commit | dc05b8549a73064337020eb3f0d8d91c8149518a (patch) | |
tree | 87f1a7f816e47e7e5bb6db25880748ec7e818c6d /src/or/microdesc.c | |
parent | bac6d542c912f733aa6103c47ef41423848fef7c (diff) | |
download | tor-dc05b8549a73064337020eb3f0d8d91c8149518a.tar.gz tor-dc05b8549a73064337020eb3f0d8d91c8149518a.zip |
Use digest256map for computing microdescriptor downloads
Diffstat (limited to 'src/or/microdesc.c')
-rw-r--r-- | src/or/microdesc.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/or/microdesc.c b/src/or/microdesc.c index e8c11a90c2..7b826008b5 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -163,19 +163,18 @@ microdescs_add_to_cache(microdesc_cache_t *cache, md->last_listed = listed_at); } if (requested_digests256) { - digestmap_t *requested; /* XXXX actually we should just use a - digest256map */ - requested = digestmap_new(); + digest256map_t *requested; + requested = digest256map_new(); /* Set requested[d] to DIGEST_REQUESTED for every md we requested. */ - SMARTLIST_FOREACH(requested_digests256, const char *, cp, - digestmap_set(requested, cp, DIGEST_REQUESTED)); + SMARTLIST_FOREACH(requested_digests256, const uint8_t *, cp, + digest256map_set(requested, cp, DIGEST_REQUESTED)); /* Set requested[d] to DIGEST_INVALID for every md we requested which we * will never be able to parse. Remove the ones we didn't request from * invalid_digests. */ - SMARTLIST_FOREACH_BEGIN(invalid_digests, char *, cp) { - if (digestmap_get(requested, cp)) { - digestmap_set(requested, cp, DIGEST_INVALID); + SMARTLIST_FOREACH_BEGIN(invalid_digests, uint8_t *, cp) { + if (digest256map_get(requested, cp)) { + digest256map_set(requested, cp, DIGEST_INVALID); } else { tor_free(cp); SMARTLIST_DEL_CURRENT(invalid_digests, cp); @@ -185,8 +184,9 @@ microdescs_add_to_cache(microdesc_cache_t *cache, * ones we never requested from the 'descriptors' smartlist. */ SMARTLIST_FOREACH_BEGIN(descriptors, microdesc_t *, md) { - if (digestmap_get(requested, md->digest)) { - digestmap_set(requested, md->digest, DIGEST_RECEIVED); + if (digest256map_get(requested, (const uint8_t*)md->digest)) { + digest256map_set(requested, (const uint8_t*)md->digest, + DIGEST_RECEIVED); } else { log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Received non-requested microdesc"); microdesc_free(md); @@ -195,14 +195,14 @@ microdescs_add_to_cache(microdesc_cache_t *cache, } SMARTLIST_FOREACH_END(md); /* Remove the ones we got or the invalid ones from requested_digests256. */ - SMARTLIST_FOREACH_BEGIN(requested_digests256, char *, cp) { - void *status = digestmap_get(requested, cp); + SMARTLIST_FOREACH_BEGIN(requested_digests256, uint8_t *, cp) { + void *status = digest256map_get(requested, cp); if (status == DIGEST_RECEIVED || status == DIGEST_INVALID) { tor_free(cp); SMARTLIST_DEL_CURRENT(requested_digests256, cp); } } SMARTLIST_FOREACH_END(cp); - digestmap_free(requested, NULL); + digest256map_free(requested, NULL); } /* For every requested microdescriptor that was unparseable, mark it @@ -794,7 +794,7 @@ microdesc_average_size(microdesc_cache_t *cache) * smartlist. Omit all microdescriptors whose digest appear in <b>skip</b>. */ smartlist_t * microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache, - int downloadable_only, digestmap_t *skip) + int downloadable_only, digest256map_t *skip) { smartlist_t *result = smartlist_new(); time_t now = time(NULL); @@ -806,7 +806,7 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache, !download_status_is_ready(&rs->dl_status, now, get_options()->TestingMicrodescMaxDownloadTries)) continue; - if (skip && digestmap_get(skip, rs->descriptor_digest)) + if (skip && digest256map_get(skip, (const uint8_t*)rs->descriptor_digest)) continue; if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN)) continue; @@ -831,7 +831,7 @@ update_microdesc_downloads(time_t now) const or_options_t *options = get_options(); networkstatus_t *consensus; smartlist_t *missing; - digestmap_t *pending; + digest256map_t *pending; if (should_delay_dir_fetches(options, NULL)) return; @@ -845,14 +845,14 @@ update_microdesc_downloads(time_t now) if (!we_fetch_microdescriptors(options)) return; - pending = digestmap_new(); + pending = digest256map_new(); list_pending_microdesc_downloads(pending); missing = microdesc_list_missing_digest256(consensus, get_microdesc_cache(), 1, pending); - digestmap_free(pending, NULL); + digest256map_free(pending, NULL); launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC, missing, NULL, now); |