|  | @@ -163,19 +163,18 @@ microdescs_add_to_cache(microdesc_cache_t *cache,
 | 
											
												
													
														|  |                        md->last_listed = listed_at);
 |  |                        md->last_listed = listed_at);
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |    if (requested_digests256) {
 |  |    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. */
 |  |      /* 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
 |  |      /* 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
 |  |       * will never be able to parse.  Remove the ones we didn't request from
 | 
											
												
													
														|  |       * invalid_digests.
 |  |       * 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 {
 |  |        } else {
 | 
											
												
													
														|  |          tor_free(cp);
 |  |          tor_free(cp);
 | 
											
												
													
														|  |          SMARTLIST_DEL_CURRENT(invalid_digests, 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.
 |  |       * ones we never requested from the 'descriptors' smartlist.
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      SMARTLIST_FOREACH_BEGIN(descriptors, microdesc_t *, md) {
 |  |      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 {
 |  |        } else {
 | 
											
												
													
														|  |          log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Received non-requested microdesc");
 |  |          log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Received non-requested microdesc");
 | 
											
												
													
														|  |          microdesc_free(md);
 |  |          microdesc_free(md);
 | 
											
										
											
												
													
														|  | @@ -195,14 +195,14 @@ microdescs_add_to_cache(microdesc_cache_t *cache,
 | 
											
												
													
														|  |      } SMARTLIST_FOREACH_END(md);
 |  |      } SMARTLIST_FOREACH_END(md);
 | 
											
												
													
														|  |      /* Remove the ones we got or the invalid ones from requested_digests256.
 |  |      /* 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) {
 |  |        if (status == DIGEST_RECEIVED || status == DIGEST_INVALID) {
 | 
											
												
													
														|  |          tor_free(cp);
 |  |          tor_free(cp);
 | 
											
												
													
														|  |          SMARTLIST_DEL_CURRENT(requested_digests256, cp);
 |  |          SMARTLIST_DEL_CURRENT(requested_digests256, cp);
 | 
											
												
													
														|  |        }
 |  |        }
 | 
											
												
													
														|  |      } SMARTLIST_FOREACH_END(cp);
 |  |      } SMARTLIST_FOREACH_END(cp);
 | 
											
												
													
														|  | -    digestmap_free(requested, NULL);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    digest256map_free(requested, NULL);
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    /* For every requested microdescriptor that was unparseable, mark it
 |  |    /* 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.  Omit all microdescriptors whose digest appear in <b>skip</b>. */
 | 
											
												
													
														|  |  smartlist_t *
 |  |  smartlist_t *
 | 
											
												
													
														|  |  microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache,
 |  |  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();
 |  |    smartlist_t *result = smartlist_new();
 | 
											
												
													
														|  |    time_t now = time(NULL);
 |  |    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,
 |  |          !download_status_is_ready(&rs->dl_status, now,
 | 
											
												
													
														|  |                    get_options()->TestingMicrodescMaxDownloadTries))
 |  |                    get_options()->TestingMicrodescMaxDownloadTries))
 | 
											
												
													
														|  |        continue;
 |  |        continue;
 | 
											
												
													
														|  | -    if (skip && digestmap_get(skip, rs->descriptor_digest))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (skip && digest256map_get(skip, (const uint8_t*)rs->descriptor_digest))
 | 
											
												
													
														|  |        continue;
 |  |        continue;
 | 
											
												
													
														|  |      if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN))
 |  |      if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN))
 | 
											
												
													
														|  |        continue;
 |  |        continue;
 | 
											
										
											
												
													
														|  | @@ -831,7 +831,7 @@ update_microdesc_downloads(time_t now)
 | 
											
												
													
														|  |    const or_options_t *options = get_options();
 |  |    const or_options_t *options = get_options();
 | 
											
												
													
														|  |    networkstatus_t *consensus;
 |  |    networkstatus_t *consensus;
 | 
											
												
													
														|  |    smartlist_t *missing;
 |  |    smartlist_t *missing;
 | 
											
												
													
														|  | -  digestmap_t *pending;
 |  | 
 | 
											
												
													
														|  | 
 |  | +  digest256map_t *pending;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    if (should_delay_dir_fetches(options, NULL))
 |  |    if (should_delay_dir_fetches(options, NULL))
 | 
											
												
													
														|  |      return;
 |  |      return;
 | 
											
										
											
												
													
														|  | @@ -845,14 +845,14 @@ update_microdesc_downloads(time_t now)
 | 
											
												
													
														|  |    if (!we_fetch_microdescriptors(options))
 |  |    if (!we_fetch_microdescriptors(options))
 | 
											
												
													
														|  |      return;
 |  |      return;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  pending = digestmap_new();
 |  | 
 | 
											
												
													
														|  | 
 |  | +  pending = digest256map_new();
 | 
											
												
													
														|  |    list_pending_microdesc_downloads(pending);
 |  |    list_pending_microdesc_downloads(pending);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    missing = microdesc_list_missing_digest256(consensus,
 |  |    missing = microdesc_list_missing_digest256(consensus,
 | 
											
												
													
														|  |                                               get_microdesc_cache(),
 |  |                                               get_microdesc_cache(),
 | 
											
												
													
														|  |                                               1,
 |  |                                               1,
 | 
											
												
													
														|  |                                               pending);
 |  |                                               pending);
 | 
											
												
													
														|  | -  digestmap_free(pending, NULL);
 |  | 
 | 
											
												
													
														|  | 
 |  | +  digest256map_free(pending, NULL);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC,
 |  |    launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC,
 | 
											
												
													
														|  |                                missing, NULL, now);
 |  |                                missing, NULL, now);
 |