Bitcoin Core  27.99.0
P2P Digital Currency
Enumerations | Functions | Variables
random.h File Reference
#include <consensus/amount.h>
#include <random.h>
#include <uint256.h>
#include <cstdint>
Include dependency graph for random.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  SeedRand { ZEROS , SEED }
 

Functions

void Seed (FastRandomContext &ctx)
 Seed the given random ctx or use the seed passed in via an environment var. More...
 
static void SeedInsecureRand (SeedRand seed=SeedRand::SEED)
 
static uint32_t InsecureRand32 ()
 
static uint256 InsecureRand256 ()
 
static uint64_t InsecureRandBits (int bits)
 
static uint64_t InsecureRandRange (uint64_t range)
 
static bool InsecureRandBool ()
 
static CAmount InsecureRandMoneyAmount ()
 

Variables

FastRandomContext g_insecure_rand_ctx
 This global and the helpers that use it are not thread-safe. More...
 
bool g_mock_deterministic_tests
 Flag to make GetRand in random.h return the same number. More...
 

Enumeration Type Documentation

◆ SeedRand

enum SeedRand
strong
Enumerator
ZEROS 

Seed with a compile time constant of zeros.

SEED 

Call the Seed() helper.

Definition at line 28 of file random.h.

Function Documentation

◆ InsecureRand256()

static uint256 InsecureRand256 ( )
inlinestatic

Definition at line 50 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsecureRand32()

static uint32_t InsecureRand32 ( )
inlinestatic

Definition at line 45 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsecureRandBits()

static uint64_t InsecureRandBits ( int  bits)
inlinestatic

Definition at line 55 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsecureRandBool()

static bool InsecureRandBool ( )
inlinestatic

Definition at line 65 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsecureRandMoneyAmount()

static CAmount InsecureRandMoneyAmount ( )
inlinestatic

Definition at line 70 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsecureRandRange()

static uint64_t InsecureRandRange ( uint64_t  range)
inlinestatic

Definition at line 60 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seed()

void Seed ( FastRandomContext ctx)

Seed the given random ctx or use the seed passed in via an environment var.

Definition at line 24 of file random.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeedInsecureRand()

static void SeedInsecureRand ( SeedRand  seed = SeedRand::SEED)
inlinestatic

Definition at line 36 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_insecure_rand_ctx

FastRandomContext g_insecure_rand_ctx
extern

This global and the helpers that use it are not thread-safe.

If thread-safety is needed, the global could be made thread_local (given that thread_local is supported on all architectures we support) or a per-thread instance could be used in the multi-threaded test.

Definition at line 14 of file random.cpp.

◆ g_mock_deterministic_tests

bool g_mock_deterministic_tests
extern

Flag to make GetRand in random.h return the same number.

Definition at line 643 of file random.cpp.