mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
random: mark RandAddPeriodic and SeedPeriodic as noexcept
The usage of MilliSleep() in SeedPeriodic (previously SeedSleep) was removed in #17270, meaning it, and its users can now be marked noexcept.
This commit is contained in:
@@ -450,17 +450,7 @@ void LockingCallbackOpenSSL(int mode, int i, const char* file, int line) NO_THRE
|
|||||||
|
|
||||||
/* A note on the use of noexcept in the seeding functions below:
|
/* A note on the use of noexcept in the seeding functions below:
|
||||||
*
|
*
|
||||||
* None of the RNG code should ever throw any exception, with the sole exception
|
* None of the RNG code should ever throw any exception.
|
||||||
* of MilliSleep in SeedSleep, which can (and does) support interruptions which
|
|
||||||
* cause a boost::thread_interrupted to be thrown.
|
|
||||||
*
|
|
||||||
* This means that SeedSleep, and all functions that invoke it are throwing.
|
|
||||||
* However, we know that GetRandBytes() and GetStrongRandBytes() never trigger
|
|
||||||
* this sleeping logic, so they are noexcept. The same is true for all the
|
|
||||||
* GetRand*() functions that use GetRandBytes() indirectly.
|
|
||||||
*
|
|
||||||
* TODO: After moving away from interruptible boost-based thread management,
|
|
||||||
* everything can become noexcept here.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void SeedTimestamp(CSHA512& hasher) noexcept
|
static void SeedTimestamp(CSHA512& hasher) noexcept
|
||||||
@@ -516,7 +506,7 @@ static void SeedStrengthen(CSHA512& hasher, RNGState& rng, int microseconds) noe
|
|||||||
Strengthen(strengthen_seed, microseconds, hasher);
|
Strengthen(strengthen_seed, microseconds, hasher);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SeedPeriodic(CSHA512& hasher, RNGState& rng)
|
static void SeedPeriodic(CSHA512& hasher, RNGState& rng) noexcept
|
||||||
{
|
{
|
||||||
// Everything that the 'fast' seeder includes
|
// Everything that the 'fast' seeder includes
|
||||||
SeedFast(hasher);
|
SeedFast(hasher);
|
||||||
@@ -598,7 +588,7 @@ static void ProcRand(unsigned char* out, int num, RNGLevel level)
|
|||||||
|
|
||||||
void GetRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::FAST); }
|
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 GetStrongRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::SLOW); }
|
||||||
void RandAddPeriodic() { ProcRand(nullptr, 0, RNGLevel::PERIODIC); }
|
void RandAddPeriodic() noexcept { ProcRand(nullptr, 0, RNGLevel::PERIODIC); }
|
||||||
|
|
||||||
bool g_mock_deterministic_tests{false};
|
bool g_mock_deterministic_tests{false};
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void GetStrongRandBytes(unsigned char* buf, int num) noexcept;
|
|||||||
*
|
*
|
||||||
* Thread-safe.
|
* Thread-safe.
|
||||||
*/
|
*/
|
||||||
void RandAddPeriodic();
|
void RandAddPeriodic() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fast randomness source. This is seeded once with secure random data, but
|
* Fast randomness source. This is seeded once with secure random data, but
|
||||||
|
|||||||
Reference in New Issue
Block a user