mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
random: replace construct/assign with explicit Reseed()
This commit is contained in:
parent
2ae392d561
commit
ce8094246e
7 changed files with 32 additions and 47 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue