[util] Add method that returns random time in milliseconds

This commit is contained in:
Amiti Uttarwar 2020-04-22 18:35:07 -07:00
parent 89eeb4a333
commit 7e93eecce3
2 changed files with 6 additions and 0 deletions

View file

@ -592,6 +592,11 @@ std::chrono::microseconds GetRandMicros(std::chrono::microseconds duration_max)
return std::chrono::microseconds{GetRand(duration_max.count())}; 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);

View file

@ -69,6 +69,7 @@
void GetRandBytes(unsigned char* buf, int num) noexcept; void GetRandBytes(unsigned char* buf, int num) noexcept;
uint64_t GetRand(uint64_t nMax) noexcept; uint64_t GetRand(uint64_t nMax) noexcept;
std::chrono::microseconds GetRandMicros(std::chrono::microseconds duration_max) noexcept; std::chrono::microseconds GetRandMicros(std::chrono::microseconds duration_max) noexcept;
std::chrono::milliseconds GetRandMillis(std::chrono::milliseconds duration_max) noexcept;
int GetRandInt(int nMax) noexcept; int GetRandInt(int nMax) noexcept;
uint256 GetRandHash() noexcept; uint256 GetRandHash() noexcept;