aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorpasta <pasta@dashboost.org>2022-01-31 19:29:33 +0700
committerpasta <pasta@dashboost.org>2022-03-23 17:36:33 -0500
commit3ae7791bcaa88f5c68592673b8926ee807242ce7 (patch)
treea3c9f0be42e9082a9047f26d4eecb65b441e39a8 /src/random.cpp
parentcea230eec40054a82fcd31fa97cf46f1585c4a35 (diff)
downloadbitcoin-3ae7791bcaa88f5c68592673b8926ee807242ce7.tar.xz
refactor: use Span in random.*
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/random.cpp b/src/random.cpp
index b862510524..2881d277ac 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -16,6 +16,7 @@
#include <logging.h> // for LogPrintf()
#include <randomenv.h>
#include <support/allocators/secure.h>
+#include <span.h>
#include <sync.h> // for Mutex
#include <util/time.h> // for GetTimeMicros()
@@ -578,8 +579,8 @@ static void ProcRand(unsigned char* out, int num, RNGLevel level) noexcept
}
}
-void GetRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::FAST); }
-void GetStrongRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::SLOW); }
+void GetRandBytes(Span<unsigned char> bytes) noexcept { ProcRand(bytes.data(), bytes.size(), RNGLevel::FAST); }
+void GetStrongRandBytes(Span<unsigned char> bytes) noexcept { ProcRand(bytes.data(), bytes.size(), RNGLevel::SLOW); }
void RandAddPeriodic() noexcept { ProcRand(nullptr, 0, RNGLevel::PERIODIC); }
void RandAddEvent(const uint32_t event_info) noexcept { GetRNGState().AddEvent(event_info); }
@@ -598,7 +599,7 @@ int GetRandInt(int nMax) noexcept
uint256 GetRandHash() noexcept
{
uint256 hash;
- GetRandBytes((unsigned char*)&hash, sizeof(hash));
+ GetRandBytes(hash);
return hash;
}