]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Rename node_has_descriptor() to node_has_any_descriptor()
authorNick Mathewson <nickm@torproject.org>
Mon, 16 Apr 2018 15:51:02 +0000 (11:51 -0400)
committerNick Mathewson <nickm@torproject.org>
Sun, 22 Apr 2018 23:43:07 +0000 (19:43 -0400)
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
src/or/control.c
src/or/nodelist.c
src/or/nodelist.h
src/or/routerlist.c
src/test/test_hs_common.c

index 96cc8369daea992d9a6551c5ed69e8d5a9657522..06aff0620017c77567d2ebb738d1faa987e6bd6e 100644 (file)
@@ -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))
index fa62e9dbdebcb6ab650090adf420e8c24d999ce6..f87a0ca4866613188c814d59c699c90a00a8761d 100644 (file)
@@ -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;
     }
index 2962d3cb40d90a54ede338acd27817bd67239b99..212606d2f74b6e6cd407c5dcb53f4768fd27e49e 100644 (file)
@@ -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));
index 5e7254f60b99e51ff7e1ad037ed70f1d94e18a3e..00f12ca1e4480ee1a972724fb5b825a6eb48af4a 100644 (file)
@@ -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);
index 2ab5017b7ac7b67d1c19e7b06d5d6ee1805afccb..1bfbd9f670109d2c06589b9d559c781b31038c4d 100644 (file)
@@ -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);
 
index 8c273c9639c48df2c10c6c0879a8cbd1d4d3b673..17ba11ca7d3a776ee48772d2ec3a2f7e62dec0ed 100644 (file)
@@ -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. */