Changeset View
Changeset View
Standalone View
Standalone View
src/random.cpp
Show First 20 Lines • Show All 636 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool g_mock_deterministic_tests{false}; | bool g_mock_deterministic_tests{false}; | ||||
uint64_t GetRand(uint64_t nMax) noexcept { | uint64_t GetRand(uint64_t nMax) noexcept { | ||||
return FastRandomContext(g_mock_deterministic_tests).randrange(nMax); | return FastRandomContext(g_mock_deterministic_tests).randrange(nMax); | ||||
} | } | ||||
std::chrono::microseconds | |||||
GetRandMicros(std::chrono::microseconds duration_max) noexcept { | |||||
return std::chrono::microseconds{GetRand(duration_max.count())}; | |||||
} | |||||
std::chrono::milliseconds | |||||
GetRandMillis(std::chrono::milliseconds duration_max) noexcept { | |||||
return std::chrono::milliseconds{GetRand(duration_max.count())}; | |||||
} | |||||
int GetRandInt(int nMax) noexcept { | int GetRandInt(int nMax) noexcept { | ||||
return GetRand(nMax); | return GetRand(nMax); | ||||
} | } | ||||
uint256 GetRandHash() noexcept { | uint256 GetRandHash() noexcept { | ||||
uint256 hash; | uint256 hash; | ||||
GetRandBytes((uint8_t *)&hash, sizeof(hash)); | GetRandBytes((uint8_t *)&hash, sizeof(hash)); | ||||
return hash; | return hash; | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |