mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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.
This commit is contained in:
parent
0f3d73a2d0
commit
47163780c3
@ -2468,7 +2468,7 @@ count_acceptable_nodes, (smartlist_t *nodes))
|
|||||||
if (! node->is_valid)
|
if (! node->is_valid)
|
||||||
// log_debug(LD_CIRC,"Nope, the directory says %d is not valid.",i);
|
// log_debug(LD_CIRC,"Nope, the directory says %d is not valid.",i);
|
||||||
continue;
|
continue;
|
||||||
if (! node_has_descriptor(node))
|
if (! node_has_any_descriptor(node))
|
||||||
continue;
|
continue;
|
||||||
/* The node has a descriptor, so we can just check the ntor key directly */
|
/* The node has a descriptor, so we can just check the ntor key directly */
|
||||||
if (!node_has_curve25519_onion_key(node))
|
if (!node_has_curve25519_onion_key(node))
|
||||||
|
@ -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);
|
connection_printf_to_buf(conn, "552 No such router \"%s\"\r\n", n);
|
||||||
goto done;
|
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);
|
connection_printf_to_buf(conn, "552 No descriptor for \"%s\"\r\n", n);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -1131,10 +1131,13 @@ node_is_dir(const node_t *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true iff <b>node</b> has either kind of usable descriptor -- that
|
/** Return true iff <b>node</b> has either kind of descriptor -- that
|
||||||
* is, a routerdescriptor or a microdescriptor. */
|
* is, a routerdescriptor or a microdescriptor.
|
||||||
|
*
|
||||||
|
* You should probably use node_has_preferred_descriptor() instead.
|
||||||
|
**/
|
||||||
int
|
int
|
||||||
node_has_descriptor(const node_t *node)
|
node_has_any_descriptor(const node_t *node)
|
||||||
{
|
{
|
||||||
return (node->ri ||
|
return (node->ri ||
|
||||||
(node->rs && node->md));
|
(node->rs && node->md));
|
||||||
|
@ -46,7 +46,7 @@ void node_get_verbose_nickname(const node_t *node,
|
|||||||
void node_get_verbose_nickname_by_id(const char *id_digest,
|
void node_get_verbose_nickname_by_id(const char *id_digest,
|
||||||
char *verbose_name_out);
|
char *verbose_name_out);
|
||||||
int node_is_dir(const node_t *node);
|
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 node_has_preferred_descriptor(const node_t *node,
|
||||||
int for_direct_connect);
|
int for_direct_connect);
|
||||||
int node_get_purpose(const node_t *node);
|
int node_get_purpose(const node_t *node);
|
||||||
|
@ -2758,7 +2758,7 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
|
|||||||
total <= 0.0) {
|
total <= 0.0) {
|
||||||
int n_with_descs = 0;
|
int n_with_descs = 0;
|
||||||
SMARTLIST_FOREACH(sl, const node_t *, node, {
|
SMARTLIST_FOREACH(sl, const node_t *, node, {
|
||||||
if (node_has_descriptor(node))
|
if (node_has_any_descriptor(node))
|
||||||
n_with_descs++;
|
n_with_descs++;
|
||||||
});
|
});
|
||||||
return ((double)n_with_descs) / (double)smartlist_len(sl);
|
return ((double)n_with_descs) / (double)smartlist_len(sl);
|
||||||
@ -2766,7 +2766,7 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
|
|||||||
|
|
||||||
present = 0.0;
|
present = 0.0;
|
||||||
SMARTLIST_FOREACH_BEGIN(sl, const node_t *, node) {
|
SMARTLIST_FOREACH_BEGIN(sl, const node_t *, node) {
|
||||||
if (node_has_descriptor(node))
|
if (node_has_any_descriptor(node))
|
||||||
present += bandwidths[node_sl_idx];
|
present += bandwidths[node_sl_idx];
|
||||||
} SMARTLIST_FOREACH_END(node);
|
} SMARTLIST_FOREACH_END(node);
|
||||||
|
|
||||||
|
@ -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);
|
node_t *node = node_get_mutable_by_id(ri->cache_info.identity_digest);
|
||||||
tt_assert(node);
|
tt_assert(node);
|
||||||
node->rs = rs;
|
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));
|
node->md = tor_malloc_zero(sizeof(microdesc_t));
|
||||||
/* Do this now the nodelist_set_routerinfo() function needs a "rs" to set
|
/* Do this now the nodelist_set_routerinfo() function needs a "rs" to set
|
||||||
* the indexes which it doesn't have when it is called. */
|
* the indexes which it doesn't have when it is called. */
|
||||||
|
Loading…
Reference in New Issue
Block a user