Commit 4249d038 authored by Mike Perry's avatar Mike Perry
Browse files

Use uniform random for L2.

We used two different min/max biases when using L2 *and* L3, but with just L2,
let's just uniform.
parent 46d621d9
......@@ -3988,17 +3988,16 @@ get_max_lifetime_of_layer2_hs_guards(void)
1, INT32_MAX);
}
/** Sample and return a lifetime for an L2 guard */
/**
* Sample and return a lifetime for an L2 guard.
*
* Lifetime randomized uniformly between min and max consensus params.
*/
static int
get_layer2_hs_guard_lifetime(void)
{
/* We use the max(x,x) distribution from prop247:
* Sample two values from the uniform distr and return the larger one */
int rand1 = crypto_rand_int_range(get_min_lifetime_of_layer2_hs_guards(),
get_max_lifetime_of_layer2_hs_guards());
int rand2 = crypto_rand_int_range(get_min_lifetime_of_layer2_hs_guards(),
get_max_lifetime_of_layer2_hs_guards());
return rand1 > rand2 ? rand1 : rand2; /* Return the max */
return crypto_rand_int_range(get_min_lifetime_of_layer2_hs_guards(),
get_max_lifetime_of_layer2_hs_guards());
}
/** Maintain the L2 guard list. Make sure the list contains enough guards, do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment