Commit f2c51cb9 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

comments and cleanups, no actual changes

parent 1a65bdd2
Loading
Loading
Loading
Loading
+36 −39
Original line number Diff line number Diff line
@@ -1808,13 +1808,10 @@ routerstatus_sl_choose_by_bandwidth(smartlist_t *sl)
  return smartlist_choose_by_bandwidth(sl, NO_WEIGHTING, 1);
}

/** Return a random running router from the routerlist.  If any node
 * named in <b>preferred</b> is available, pick one of those.  Never
/** Return a random running router from the routerlist. Never
 * pick a node whose routerinfo is in
 * <b>excludedsmartlist</b>, or whose routerinfo matches <b>excludedset</b>,
 * even if they are the only nodes
 * available.  If <b>CRN_STRICT_PREFERRED</b> is set in flags, never pick
 * any node besides those in <b>preferred</b>.
 * even if they are the only nodes available.
 * If <b>CRN_NEED_UPTIME</b> is set in flags and any router has more than
 * a minimum uptime, return one of those.
 * If <b>CRN_NEED_CAPACITY</b> is set in flags, weight your choice by the
@@ -1837,7 +1834,8 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
  const int allow_invalid = (flags & CRN_ALLOW_INVALID) != 0;
  const int weight_for_exit = (flags & CRN_WEIGHT_AS_EXIT) != 0;

  smartlist_t *sl, *excludednodes;
  smartlist_t *sl=smartlist_create(),
              *excludednodes=smartlist_create();
  routerinfo_t *choice = NULL, *r;
  bandwidth_weight_rule_t rule;

@@ -1845,8 +1843,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
  rule = weight_for_exit ? WEIGHT_FOR_EXIT :
    (need_guard ? WEIGHT_FOR_GUARD : NO_WEIGHTING);

  excludednodes = smartlist_create();

  /* Exclude relays that allow single hop exit circuits, if the user
   * wants to (such relays might be risky) */
  if (get_options()->ExcludeSingleHopRelays) {
@@ -1862,8 +1858,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
    routerlist_add_family(excludednodes, r);
  }

  { /* XXX021 reformat */
    sl = smartlist_create();
  router_add_running_routers_to_smartlist(sl, allow_invalid,
                                          need_uptime, need_capacity,
                                          need_guard);
@@ -1891,7 +1885,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
    choice = router_choose_random_node(
                     excludedsmartlist, excludedset, flags);
  }
  }
  smartlist_free(excludednodes);
  if (!choice) {
    log_warn(LD_CIRC,
@@ -5184,9 +5177,13 @@ routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
  }
}

/** Add to <b>target</b> every routerinfo_t from <b>source</b> that is in
 * <b>include</b>, but not excluded in a more specific fashion by
 * <b>exclude</b>.  If <b>running_only</b>, only include running routers.
/** Add to <b>target</b> every routerinfo_t from <b>source</b> except:
 *
 * 1) Don't add it if <b>include</b> is non-empty and the relay isn't in
 * <b>include</b>; and
 * 2) Don't add it if <b>exclude</b> is non-empty and the relay is
 * excluded in a more specific fashion by <b>exclude</b>.
 * 3) If <b>running_only</b>, don't add non-running routers.
 */
void
routersets_get_disjunction(smartlist_t *target,