mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
4ffda340d3
And turn "" includes into full-path (which makes it easier to put config.h first, and finds some cases check-includes.sh missed previously). config.h sets _GNU_SOURCE which really needs to be done before any '#includes': we mainly got away with it with glibc, but other platforms like Alpine may have stricter requirements. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
13 lines
256 B
C
13 lines
256 B
C
#include "config.h"
|
|
#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;
|
|
}
|