random: replace construct/assign with explicit Reseed()

This commit is contained in:
Pieter Wuille
2024-05-31 10:39:23 -04:00
parent 2ae392d561
commit ce8094246e
7 changed files with 32 additions and 47 deletions

View File

@@ -704,6 +704,13 @@ void FastRandomContext::fillrand(Span<std::byte> output) noexcept
FastRandomContext::FastRandomContext(const uint256& seed) noexcept : requires_seed(false), rng(MakeByteSpan(seed)) {}
void FastRandomContext::Reseed(const uint256& seed) noexcept
{
FlushCache();
requires_seed = false;
rng = {MakeByteSpan(seed)};
}
bool Random_SanityCheck()
{
uint64_t start = GetPerformanceCounter();
@@ -759,15 +766,6 @@ FastRandomContext::FastRandomContext(bool fDeterministic) noexcept : requires_se
// use.
}
FastRandomContext& FastRandomContext::operator=(FastRandomContext&& from) noexcept
{
requires_seed = from.requires_seed;
rng = from.rng;
from.requires_seed = true;
static_cast<RandomMixin<FastRandomContext>&>(*this) = std::move(from);
return *this;
}
void RandomInit()
{
// Invoke RNG code to trigger initialization (if not already performed)