commit 80fa404625b757cbde07be76abf848efadab7c46 Author: Nick Mathewson nickm@torproject.org Date: Tue Nov 29 12:48:32 2016 -0500
Fix for small test networks: don't refuse to have any sampled guards.
Don't restrict the sample size if the network size is less than 20 guards. Maybe we'll think of a better rule later on? --- src/or/entrynodes.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 3ba0179..8380dbf 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -891,6 +891,23 @@ num_reachable_filtered_guards(guard_selection_t *gs) return n_reachable_filtered_guards; }
+/** Return the actual maximum size for the sample in <b>gs</b>, + * given that we know about <b>n_guards</b> total. */ +static int +get_max_sample_size(guard_selection_t *gs, + int n_guards) +{ + const int using_bridges = (gs->type == GS_TYPE_BRIDGE); + + /* XXXX prop271 spec deviation with bridges, max_sample is "all of them" */ + if (using_bridges) + return n_guards; + else if (n_guards < 20) // XXXX prop271 spec deviation + return n_guards; + else + return (int)(n_guards * get_max_sample_threshold()); +} + /** * Return a smartlist of the all the guards that are not currently * members of the sample (GUARDS - SAMPLED_GUARDS). The elements of @@ -987,11 +1004,7 @@ entry_guards_expand_sample(guard_selection_t *gs) int n_guards = 0; smartlist_t *eligible_guards = get_eligible_guards(gs, &n_guards);
- const int using_bridges = (gs->type == GS_TYPE_BRIDGE); - - /* XXXX prop271 spec deviation with bridges, max_sample is "all of them" */ - const int max_sample = using_bridges ? n_guards : - (int)(n_guards * get_max_sample_threshold()); + const int max_sample = get_max_sample_size(gs, n_guards); const int min_filtered_sample = get_min_filtered_sample_size();
log_info(LD_GUARD, "Expanding the sample guard set. We have %d guards "