MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetRand

Function GetRand

src/random.cpp:353–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353uint64_t GetRand(uint64_t nMax)
354{
355 if (nMax == 0)
356 return 0;
357
358 // The range of the random source must be a multiple of the modulus
359 // to give every possible output value an equal possibility
360 uint64_t nRange = (std::numeric_limits<uint64_t>::max() / nMax) * nMax;
361 uint64_t nRand = 0;
362 do {
363 GetRandBytes((unsigned char*)&nRand, sizeof(nRand));
364 } while (nRand >= nRange);
365 return (nRand % nMax);
366}
367
368int GetRandInt(int nMax)
369{

Callers 15

GetRandIntFunction · 0.85
checkMethod · 0.85
SaltedTxidHasherMethod · 0.85
ProcessMessageFunction · 0.85
AppInitMainFunction · 0.85
SaltedOutpointHasherMethod · 0.85
resetMethod · 0.85
convertSeed6Function · 0.85
AdvertiseLocalFunction · 0.85
ConnectNodeMethod · 0.85
ThreadDNSAddressSeedMethod · 0.85

Calls 2

maxFunction · 0.85
GetRandBytesFunction · 0.85

Tested by 3

BuildChainFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
mainFunction · 0.68