mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
simplify functions now that they don't use options param
This commit is contained in:
parent
2330a3713d
commit
466e27feae
@ -2469,10 +2469,8 @@ networkstatus_parse_flavor_name(const char *flavname)
|
|||||||
* running, or otherwise not a descriptor that we would make any
|
* running, or otherwise not a descriptor that we would make any
|
||||||
* use of even if we had it. Else return 1. */
|
* use of even if we had it. Else return 1. */
|
||||||
int
|
int
|
||||||
client_would_use_router(const routerstatus_t *rs, time_t now,
|
client_would_use_router(const routerstatus_t *rs, time_t now)
|
||||||
const or_options_t *options)
|
|
||||||
{
|
{
|
||||||
(void) options; /* unused */
|
|
||||||
if (!rs->is_flagged_running) {
|
if (!rs->is_flagged_running) {
|
||||||
/* If we had this router descriptor, we wouldn't even bother using it.
|
/* If we had this router descriptor, we wouldn't even bother using it.
|
||||||
* (Fetching and storing depends on by we_want_to_fetch_flavor().) */
|
* (Fetching and storing depends on by we_want_to_fetch_flavor().) */
|
||||||
|
@ -76,8 +76,7 @@ int should_delay_dir_fetches(const or_options_t *options,const char **msg_out);
|
|||||||
void update_networkstatus_downloads(time_t now);
|
void update_networkstatus_downloads(time_t now);
|
||||||
void update_certificate_downloads(time_t now);
|
void update_certificate_downloads(time_t now);
|
||||||
int consensus_is_waiting_for_certs(void);
|
int consensus_is_waiting_for_certs(void);
|
||||||
int client_would_use_router(const routerstatus_t *rs, time_t now,
|
int client_would_use_router(const routerstatus_t *rs, time_t now);
|
||||||
const or_options_t *options);
|
|
||||||
MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus,(void));
|
MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus,(void));
|
||||||
MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus_by_flavor,
|
MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus_by_flavor,
|
||||||
(consensus_flavor_t f));
|
(consensus_flavor_t f));
|
||||||
|
@ -74,7 +74,6 @@ static void count_usable_descriptors(int *num_present,
|
|||||||
int *num_usable,
|
int *num_usable,
|
||||||
smartlist_t *descs_out,
|
smartlist_t *descs_out,
|
||||||
const networkstatus_t *consensus,
|
const networkstatus_t *consensus,
|
||||||
const or_options_t *options,
|
|
||||||
time_t now,
|
time_t now,
|
||||||
routerset_t *in_set,
|
routerset_t *in_set,
|
||||||
usable_descriptor_t exit_only);
|
usable_descriptor_t exit_only);
|
||||||
@ -1690,7 +1689,7 @@ static void
|
|||||||
count_usable_descriptors(int *num_present, int *num_usable,
|
count_usable_descriptors(int *num_present, int *num_usable,
|
||||||
smartlist_t *descs_out,
|
smartlist_t *descs_out,
|
||||||
const networkstatus_t *consensus,
|
const networkstatus_t *consensus,
|
||||||
const or_options_t *options, time_t now,
|
time_t now,
|
||||||
routerset_t *in_set,
|
routerset_t *in_set,
|
||||||
usable_descriptor_t exit_only)
|
usable_descriptor_t exit_only)
|
||||||
{
|
{
|
||||||
@ -1707,7 +1706,7 @@ count_usable_descriptors(int *num_present, int *num_usable,
|
|||||||
continue;
|
continue;
|
||||||
if (in_set && ! routerset_contains_routerstatus(in_set, rs, -1))
|
if (in_set && ! routerset_contains_routerstatus(in_set, rs, -1))
|
||||||
continue;
|
continue;
|
||||||
if (client_would_use_router(rs, now, options)) {
|
if (client_would_use_router(rs, now)) {
|
||||||
const char * const digest = rs->descriptor_digest;
|
const char * const digest = rs->descriptor_digest;
|
||||||
int present;
|
int present;
|
||||||
++*num_usable; /* the consensus says we want it. */
|
++*num_usable; /* the consensus says we want it. */
|
||||||
@ -1761,10 +1760,10 @@ compute_frac_paths_available(const networkstatus_t *consensus,
|
|||||||
const int authdir = authdir_mode_v3(options);
|
const int authdir = authdir_mode_v3(options);
|
||||||
|
|
||||||
count_usable_descriptors(num_present_out, num_usable_out,
|
count_usable_descriptors(num_present_out, num_usable_out,
|
||||||
mid, consensus, options, now, NULL,
|
mid, consensus, now, NULL,
|
||||||
USABLE_DESCRIPTOR_ALL);
|
USABLE_DESCRIPTOR_ALL);
|
||||||
if (options->EntryNodes) {
|
if (options->EntryNodes) {
|
||||||
count_usable_descriptors(&np, &nu, guards, consensus, options, now,
|
count_usable_descriptors(&np, &nu, guards, consensus, now,
|
||||||
options->EntryNodes, USABLE_DESCRIPTOR_ALL);
|
options->EntryNodes, USABLE_DESCRIPTOR_ALL);
|
||||||
} else {
|
} else {
|
||||||
SMARTLIST_FOREACH(mid, const node_t *, node, {
|
SMARTLIST_FOREACH(mid, const node_t *, node, {
|
||||||
@ -1785,7 +1784,7 @@ compute_frac_paths_available(const networkstatus_t *consensus,
|
|||||||
* an unavoidable feature of forcing authorities to declare
|
* an unavoidable feature of forcing authorities to declare
|
||||||
* certain nodes as exits.
|
* certain nodes as exits.
|
||||||
*/
|
*/
|
||||||
count_usable_descriptors(&np, &nu, exits, consensus, options, now,
|
count_usable_descriptors(&np, &nu, exits, consensus, now,
|
||||||
NULL, USABLE_DESCRIPTOR_EXIT_ONLY);
|
NULL, USABLE_DESCRIPTOR_EXIT_ONLY);
|
||||||
log_debug(LD_NET,
|
log_debug(LD_NET,
|
||||||
"%s: %d present, %d usable",
|
"%s: %d present, %d usable",
|
||||||
@ -1834,7 +1833,7 @@ compute_frac_paths_available(const networkstatus_t *consensus,
|
|||||||
smartlist_t *myexits_unflagged = smartlist_new();
|
smartlist_t *myexits_unflagged = smartlist_new();
|
||||||
|
|
||||||
/* All nodes with exit flag in ExitNodes option */
|
/* All nodes with exit flag in ExitNodes option */
|
||||||
count_usable_descriptors(&np, &nu, myexits, consensus, options, now,
|
count_usable_descriptors(&np, &nu, myexits, consensus, now,
|
||||||
options->ExitNodes, USABLE_DESCRIPTOR_EXIT_ONLY);
|
options->ExitNodes, USABLE_DESCRIPTOR_EXIT_ONLY);
|
||||||
log_debug(LD_NET,
|
log_debug(LD_NET,
|
||||||
"%s: %d present, %d usable",
|
"%s: %d present, %d usable",
|
||||||
@ -1845,7 +1844,7 @@ compute_frac_paths_available(const networkstatus_t *consensus,
|
|||||||
/* Now compute the nodes in the ExitNodes option where which we don't know
|
/* Now compute the nodes in the ExitNodes option where which we don't know
|
||||||
* what their exit policy is, or we know it permits something. */
|
* what their exit policy is, or we know it permits something. */
|
||||||
count_usable_descriptors(&np, &nu, myexits_unflagged,
|
count_usable_descriptors(&np, &nu, myexits_unflagged,
|
||||||
consensus, options, now,
|
consensus, now,
|
||||||
options->ExitNodes, USABLE_DESCRIPTOR_ALL);
|
options->ExitNodes, USABLE_DESCRIPTOR_ALL);
|
||||||
log_debug(LD_NET,
|
log_debug(LD_NET,
|
||||||
"%s: %d present, %d usable",
|
"%s: %d present, %d usable",
|
||||||
|
@ -5142,7 +5142,7 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
|||||||
continue; /* We would throw it out immediately. */
|
continue; /* We would throw it out immediately. */
|
||||||
}
|
}
|
||||||
if (!we_want_to_fetch_flavor(options, consensus->flavor) &&
|
if (!we_want_to_fetch_flavor(options, consensus->flavor) &&
|
||||||
!client_would_use_router(rs, now, options)) {
|
!client_would_use_router(rs, now)) {
|
||||||
++n_wouldnt_use;
|
++n_wouldnt_use;
|
||||||
continue; /* We would never use it ourself. */
|
continue; /* We would never use it ourself. */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user