mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
496c0dd1e6
Turns out we can make quite a simple API out of it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
12 lines
236 B
C
12 lines
236 B
C
#include <common/pseudorand.h>
|
|
#include <common/random_select.h>
|
|
|
|
bool random_select(double weight, double *tot_weight)
|
|
{
|
|
*tot_weight += weight;
|
|
if (weight == 0)
|
|
return false;
|
|
|
|
return pseudorand_double() <= weight / *tot_weight;
|
|
}
|