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 SeedRandomForTest (SeedRand seed=SeedRand::SEED)
 Seed the RNG for testing. More...
 
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...
 

Enumeration Type Documentation

◆ SeedRand

enum SeedRand
strong
Enumerator
ZEROS 

Seed with a compile time constant of zeros.

SEED 

Use (and report) random seed from environment, or a (truly) random one.

Definition at line 22 of file random.h.

Function Documentation

◆ InsecureRand256()

static uint256 InsecureRand256 ( )
inlinestatic

Definition at line 35 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 30 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 40 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 50 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 55 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 45 of file random.h.

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

◆ SeedRandomForTest()

void SeedRandomForTest ( SeedRand  seed = SeedRand::SEED)

Seed the RNG for testing.

This affects all randomness, except GetStrongRandBytes().

Definition at line 18 of file random.cpp.

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, a per-thread instance could be used in the multi-threaded test.

Definition at line 14 of file random.cpp.