diff --git a/src/random.cpp b/src/random.cpp index d6068e958fb..89651f70712 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -652,14 +652,14 @@ uint256 GetRandHash() noexcept return hash; } -void FastRandomContext::RandomSeed() +void FastRandomContext::RandomSeed() noexcept { uint256 seed = GetRandHash(); rng.SetKey(MakeByteSpan(seed)); requires_seed = false; } -void FastRandomContext::fillrand(Span output) +void FastRandomContext::fillrand(Span output) noexcept { if (requires_seed) RandomSeed(); rng.Keystream(output); diff --git a/src/random.h b/src/random.h index ab9686c5b94..b4c42a42bba 100644 --- a/src/random.h +++ b/src/random.h @@ -150,9 +150,9 @@ private: uint64_t bitbuf; int bitbuf_size; - void RandomSeed(); + void RandomSeed() noexcept; - void FillBitBuffer() + void FillBitBuffer() noexcept { bitbuf = rand64(); bitbuf_size = 64; @@ -213,7 +213,7 @@ public: /** Generate random bytes. */ template - std::vector randbytes(size_t len) + std::vector randbytes(size_t len) noexcept { std::vector ret(len); fillrand(MakeWritableByteSpan(ret)); @@ -221,7 +221,7 @@ public: } /** Fill a byte Span with random bytes. */ - void fillrand(Span output); + void fillrand(Span output) noexcept; /** Generate a random 32-bit integer. */ uint32_t rand32() noexcept { return randbits(32); } @@ -239,7 +239,7 @@ public: /** Return the time point advanced by a uniform random duration. */ template - Tp rand_uniform_delay(const Tp& time, typename Tp::duration range) + Tp rand_uniform_delay(const Tp& time, typename Tp::duration range) noexcept { return time + rand_uniform_duration(range); } @@ -256,8 +256,8 @@ public: // Compatibility with the UniformRandomBitGenerator concept typedef uint64_t result_type; - static constexpr uint64_t min() { return 0; } - static constexpr uint64_t max() { return std::numeric_limits::max(); } + static constexpr uint64_t min() noexcept { return 0; } + static constexpr uint64_t max() noexcept { return std::numeric_limits::max(); } inline uint64_t operator()() noexcept { return rand64(); } };