[tor-commits] [tor/master] Rename node_has_descriptor() to node_has_any_descriptor()
nickm at torproject.org
nickm at torproject.org
Sun Apr 22 23:44:36 UTC 2018
commit 47163780c3682d881ad6e8044320a57fce439ea1
Author: Nick Mathewson <nickm at torproject.org>
Date: Mon Apr 16 11:51:02 2018 -0400
Rename node_has_descriptor() to node_has_any_descriptor()
Changing the name of this function should help keep us from misusing
it when node_has_preferred_descriptor() would be more appropriate.
---
src/or/circuitbuild.c | 2 +-
src/or/control.c | 2 +-
src/or/nodelist.c | 9 ++++++---
src/or/nodelist.h | 2 +-
src/or/routerlist.c | 4 ++--
src/test/test_hs_common.c | 3 ++-
6 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 96cc8369d..06aff0620 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2468,7 +2468,7 @@ count_acceptable_nodes, (smartlist_t *nodes))
if (! node->is_valid)
// log_debug(LD_CIRC,"Nope, the directory says %d is not valid.",i);
continue;
- if (! node_has_descriptor(node))
+ if (! node_has_any_descriptor(node))
continue;
/* The node has a descriptor, so we can just check the ntor key directly */
if (!node_has_curve25519_onion_key(node))
diff --git a/src/or/control.c b/src/or/control.c
index fa62e9dbd..f87a0ca48 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3498,7 +3498,7 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len,
connection_printf_to_buf(conn, "552 No such router \"%s\"\r\n", n);
goto done;
}
- if (!node_has_descriptor(node)) {
+ if (!node_has_any_descriptor(node)) {
connection_printf_to_buf(conn, "552 No descriptor for \"%s\"\r\n", n);
goto done;
}
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 2962d3cb4..212606d2f 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1131,10 +1131,13 @@ node_is_dir(const node_t *node)
}
}
-/** Return true iff <b>node</b> has either kind of usable descriptor -- that
- * is, a routerdescriptor or a microdescriptor. */
+/** Return true iff <b>node</b> has either kind of descriptor -- that
+ * is, a routerdescriptor or a microdescriptor.
+ *
+ * You should probably use node_has_preferred_descriptor() instead.
+ **/
int
-node_has_descriptor(const node_t *node)
+node_has_any_descriptor(const node_t *node)
{
return (node->ri ||
(node->rs && node->md));
diff --git a/src/or/nodelist.h b/src/or/nodelist.h
index 5e7254f60..00f12ca1e 100644
--- a/src/or/nodelist.h
+++ b/src/or/nodelist.h
@@ -46,7 +46,7 @@ void node_get_verbose_nickname(const node_t *node,
void node_get_verbose_nickname_by_id(const char *id_digest,
char *verbose_name_out);
int node_is_dir(const node_t *node);
-int node_has_descriptor(const node_t *node);
+int node_has_any_descriptor(const node_t *node);
int node_has_preferred_descriptor(const node_t *node,
int for_direct_connect);
int node_get_purpose(const node_t *node);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 2ab5017b7..1bfbd9f67 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2758,7 +2758,7 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
total <= 0.0) {
int n_with_descs = 0;
SMARTLIST_FOREACH(sl, const node_t *, node, {
- if (node_has_descriptor(node))
+ if (node_has_any_descriptor(node))
n_with_descs++;
});
return ((double)n_with_descs) / (double)smartlist_len(sl);
@@ -2766,7 +2766,7 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
present = 0.0;
SMARTLIST_FOREACH_BEGIN(sl, const node_t *, node) {
- if (node_has_descriptor(node))
+ if (node_has_any_descriptor(node))
present += bandwidths[node_sl_idx];
} SMARTLIST_FOREACH_END(node);
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index 8c273c963..17ba11ca7 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -305,7 +305,8 @@ helper_add_hsdir_to_networkstatus(networkstatus_t *ns,
node_t *node = node_get_mutable_by_id(ri->cache_info.identity_digest);
tt_assert(node);
node->rs = rs;
- /* We need this to exist for node_has_descriptor() to return true. */
+ /* We need this to exist for node_has_preferred_descriptor() to return
+ * true. */
node->md = tor_malloc_zero(sizeof(microdesc_t));
/* Do this now the nodelist_set_routerinfo() function needs a "rs" to set
* the indexes which it doesn't have when it is called. */
More information about the tor-commits
mailing list