Rename router_get_by_digest()

We now call the function router_get_by_id_digest() to make clear that
we're talking about the identity digest here, not descriptor digest.
This commit is contained in:
Sebastian Hahn 2010-10-14 17:49:51 +02:00
parent 376939c9ac
commit 4556f2e7c8
8 changed files with 17 additions and 17 deletions

View File

@ -622,7 +622,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
/** Warn when we get a netinfo skew with at least this value. */ /** Warn when we get a netinfo skew with at least this value. */
#define NETINFO_NOTICE_SKEW 3600 #define NETINFO_NOTICE_SKEW 3600
if (labs(apparent_skew) > NETINFO_NOTICE_SKEW && if (labs(apparent_skew) > NETINFO_NOTICE_SKEW &&
router_get_by_digest(conn->identity_digest)) { router_get_by_id_digest(conn->identity_digest)) {
char dbuf[64]; char dbuf[64];
int severity; int severity;
/*XXXX be smarter about when everybody says we are skewed. */ /*XXXX be smarter about when everybody says we are skewed. */

View File

@ -360,7 +360,7 @@ connection_or_digest_is_known_relay(const char *id_digest)
{ {
if (router_get_consensus_status_by_id(id_digest)) if (router_get_consensus_status_by_id(id_digest))
return 1; /* It's in the consensus: "yes" */ return 1; /* It's in the consensus: "yes" */
if (router_get_by_digest(id_digest)) if (router_get_by_id_digest(id_digest))
return 1; /* Not in the consensus, but we have a descriptor for return 1; /* Not in the consensus, but we have a descriptor for
* it. Probably it was in a recent consensus. "Yes". */ * it. Probably it was in a recent consensus. "Yes". */
return 0; return 0;
@ -1342,7 +1342,7 @@ connection_or_set_state_open(or_connection_t *conn)
router_set_status(conn->identity_digest, 1); router_set_status(conn->identity_digest, 1);
} else { } else {
/* only report it to the geoip module if it's not a known router */ /* only report it to the geoip module if it's not a known router */
if (!router_get_by_digest(conn->identity_digest)) { if (!router_get_by_id_digest(conn->identity_digest)) {
if (tor_addr_family(&TO_CONN(conn)->addr) == AF_INET) { if (tor_addr_family(&TO_CONN(conn)->addr) == AF_INET) {
/*XXXX IP6 support ipv6 geoip.*/ /*XXXX IP6 support ipv6 geoip.*/
uint32_t a = tor_addr_to_ipv4h(&TO_CONN(conn)->addr); uint32_t a = tor_addr_to_ipv4h(&TO_CONN(conn)->addr);

View File

@ -780,7 +780,7 @@ dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)
tor_assert(msg); tor_assert(msg);
*msg = NULL; *msg = NULL;
ri = router_get_by_digest(ei->cache_info.identity_digest); ri = router_get_by_id_digest(ei->cache_info.identity_digest);
if (!ri) { if (!ri) {
*msg = "No corresponding router descriptor for extra-info descriptor"; *msg = "No corresponding router descriptor for extra-info descriptor";
extrainfo_free(ei); extrainfo_free(ei);
@ -2057,7 +2057,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
} }
if (format != NS_V2) { if (format != NS_V2) {
const routerinfo_t* desc = router_get_by_digest(rs->identity_digest); const routerinfo_t* desc = router_get_by_id_digest(rs->identity_digest);
uint32_t bw; uint32_t bw;
if (format != NS_CONTROL_PORT) { if (format != NS_CONTROL_PORT) {
@ -3099,7 +3099,7 @@ dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
if (ri) if (ri)
smartlist_add(descs_out, (void*) &(ri->cache_info)); smartlist_add(descs_out, (void*) &(ri->cache_info));
} else { } else {
const routerinfo_t *ri = router_get_by_digest(d); const routerinfo_t *ri = router_get_by_id_digest(d);
/* Don't actually serve a descriptor that everyone will think is /* Don't actually serve a descriptor that everyone will think is
* expired. This is an (ugly) workaround to keep buggy 0.1.1.10 * expired. This is an (ugly) workaround to keep buggy 0.1.1.10
* Tors from downloading descriptors that they will throw away. * Tors from downloading descriptors that they will throw away.
@ -3299,7 +3299,7 @@ get_signed_descriptor_by_fp(const char *fp, int extrainfo,
else else
return &(router_get_my_routerinfo()->cache_info); return &(router_get_my_routerinfo()->cache_info);
} else { } else {
const routerinfo_t *ri = router_get_by_digest(fp); const routerinfo_t *ri = router_get_by_id_digest(fp);
if (ri && if (ri &&
ri->cache_info.published_on > publish_cutoff) { ri->cache_info.published_on > publish_cutoff) {
if (extrainfo) if (extrainfo)

View File

@ -415,7 +415,7 @@ directory_get_from_hs_dir(const char *desc_id, const rend_data_t *rend_query)
SMARTLIST_FOREACH(responsible_dirs, routerstatus_t *, dir, { SMARTLIST_FOREACH(responsible_dirs, routerstatus_t *, dir, {
if (lookup_last_hid_serv_request(dir, desc_id_base32, 0, 0) + if (lookup_last_hid_serv_request(dir, desc_id_base32, 0, 0) +
REND_HID_SERV_DIR_REQUERY_PERIOD >= now || REND_HID_SERV_DIR_REQUERY_PERIOD >= now ||
!router_get_by_digest(dir->identity_digest)) !router_get_by_id_digest(dir->identity_digest))
SMARTLIST_DEL_CURRENT(responsible_dirs, dir); SMARTLIST_DEL_CURRENT(responsible_dirs, dir);
}); });

View File

@ -1578,7 +1578,7 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
hs_dir->identity_digest)) hs_dir->identity_digest))
/* Don't upload descriptor if we succeeded in doing so last time. */ /* Don't upload descriptor if we succeeded in doing so last time. */
continue; continue;
if (!router_get_by_digest(hs_dir->identity_digest)) { if (!router_get_by_id_digest(hs_dir->identity_digest)) {
log_info(LD_REND, "Not sending publish request for v2 descriptor to " log_info(LD_REND, "Not sending publish request for v2 descriptor to "
"hidden service directory '%s'; we don't have its " "hidden service directory '%s'; we don't have its "
"router descriptor. Queuing for later upload.", "router descriptor. Queuing for later upload.",

View File

@ -757,7 +757,7 @@ rep_hist_record_mtbf_data(time_t now, int missing_means_down)
base16_encode(dbuf, sizeof(dbuf), digest, DIGEST_LEN); base16_encode(dbuf, sizeof(dbuf), digest, DIGEST_LEN);
if (missing_means_down && hist->start_of_run && if (missing_means_down && hist->start_of_run &&
!router_get_by_digest(digest)) { !router_get_by_id_digest(digest)) {
/* We think this relay is running, but it's not listed in our /* We think this relay is running, but it's not listed in our
* routerlist. Somehow it fell out without telling us it went * routerlist. Somehow it fell out without telling us it went
* down. Complain and also correct it. */ * down. Complain and also correct it. */

View File

@ -2462,7 +2462,7 @@ router_get_by_nickname(const char *nickname, int warn_if_unnamed)
int int
router_digest_version_as_new_as(const char *digest, const char *cutoff) router_digest_version_as_new_as(const char *digest, const char *cutoff)
{ {
const routerinfo_t *router = router_get_by_digest(digest); const routerinfo_t *router = router_get_by_id_digest(digest);
if (!router) if (!router)
return 1; return 1;
return tor_version_as_new_as(router->platform, cutoff); return tor_version_as_new_as(router->platform, cutoff);
@ -2526,7 +2526,7 @@ router_get_by_hexdigest(const char *hexdigest)
return router_get_by_nickname(hexdigest, 1); return router_get_by_nickname(hexdigest, 1);
} }
/** As router_get_by_digest,but return a pointer that you're allowed to /** As router_get_by_id_digest,but return a pointer that you're allowed to
* modify */ * modify */
routerinfo_t * routerinfo_t *
router_get_mutable_by_digest(const char *digest) router_get_mutable_by_digest(const char *digest)
@ -2543,7 +2543,7 @@ router_get_mutable_by_digest(const char *digest)
/** Return the router in our routerlist whose 20-byte key digest /** Return the router in our routerlist whose 20-byte key digest
* is <b>digest</b>. Return NULL if no such router is known. */ * is <b>digest</b>. Return NULL if no such router is known. */
const routerinfo_t * const routerinfo_t *
router_get_by_digest(const char *digest) router_get_by_id_digest(const char *digest)
{ {
return router_get_mutable_by_digest(digest); return router_get_mutable_by_digest(digest);
} }
@ -4610,7 +4610,7 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
if ((sd = router_get_by_descriptor_digest(rs->descriptor_digest))) { if ((sd = router_get_by_descriptor_digest(rs->descriptor_digest))) {
const routerinfo_t *ri; const routerinfo_t *ri;
++n_have; ++n_have;
if (!(ri = router_get_by_digest(rs->identity_digest)) || if (!(ri = router_get_by_id_digest(rs->identity_digest)) ||
memcmp(ri->cache_info.signed_descriptor_digest, memcmp(ri->cache_info.signed_descriptor_digest,
sd->signed_descriptor_digest, DIGEST_LEN)) { sd->signed_descriptor_digest, DIGEST_LEN)) {
/* We have a descriptor with this digest, but either there is no /* We have a descriptor with this digest, but either there is no
@ -4644,7 +4644,7 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
char time_bufnew[ISO_TIME_LEN+1]; char time_bufnew[ISO_TIME_LEN+1];
char time_bufold[ISO_TIME_LEN+1]; char time_bufold[ISO_TIME_LEN+1];
const routerinfo_t *oldrouter; const routerinfo_t *oldrouter;
oldrouter = router_get_by_digest(rs->identity_digest); oldrouter = router_get_by_id_digest(rs->identity_digest);
format_iso_time(time_bufnew, rs->published_on); format_iso_time(time_bufnew, rs->published_on);
if (oldrouter) if (oldrouter)
format_iso_time(time_bufold, oldrouter->cache_info.published_on); format_iso_time(time_bufold, oldrouter->cache_info.published_on);
@ -4765,7 +4765,7 @@ update_extrainfo_downloads(time_t now)
sd = &((routerinfo_t*)smartlist_get(lst, i))->cache_info; sd = &((routerinfo_t*)smartlist_get(lst, i))->cache_info;
if (sd->is_extrainfo) if (sd->is_extrainfo)
continue; /* This should never happen. */ continue; /* This should never happen. */
if (old_routers && !router_get_by_digest(sd->identity_digest)) if (old_routers && !router_get_by_id_digest(sd->identity_digest))
continue; /* Couldn't check the signature if we got it. */ continue; /* Couldn't check the signature if we got it. */
if (sd->extrainfo_is_bogus) if (sd->extrainfo_is_bogus)
continue; continue;

View File

@ -65,7 +65,7 @@ int router_digest_is_trusted_dir_type(const char *digest,
int router_addr_is_trusted_dir(uint32_t addr); int router_addr_is_trusted_dir(uint32_t addr);
int hexdigest_to_digest(const char *hexdigest, char *digest); int hexdigest_to_digest(const char *hexdigest, char *digest);
const routerinfo_t *router_get_by_hexdigest(const char *hexdigest); const routerinfo_t *router_get_by_hexdigest(const char *hexdigest);
const routerinfo_t *router_get_by_digest(const char *digest); const routerinfo_t *router_get_by_id_digest(const char *digest);
routerinfo_t *router_get_mutable_by_digest(const char *digest); routerinfo_t *router_get_mutable_by_digest(const char *digest);
signed_descriptor_t *router_get_by_descriptor_digest(const char *digest); signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest); signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);