aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2019-11-18 10:21:28 -0500
committerfanquake <fanquake@gmail.com>2019-11-18 10:22:17 -0500
commit55b2cb199c276781b6daa5438af2da57dea3ac52 (patch)
tree9569dd0449461ac6ffa5cd3b05d3bf5a07b0cc43 /src/random.cpp
parent461e547877da0c04db69e067c923cc4540aab03a (diff)
downloadbitcoin-55b2cb199c276781b6daa5438af2da57dea3ac52.tar.xz
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.
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/random.cpp b/src/random.cpp
index c78a34ea45..8c33e1260b 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -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:
*
- * None of the RNG code should ever throw any exception, with the sole 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.
+ * None of the RNG code should ever throw any exception.
*/
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);
}
-static void SeedPeriodic(CSHA512& hasher, RNGState& rng)
+static void SeedPeriodic(CSHA512& hasher, RNGState& rng) noexcept
{
// Everything that the 'fast' seeder includes
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 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};