aboutsummaryrefslogtreecommitdiff
path: root/src/random.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/random.h')
-rw-r--r--src/random.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/random.h b/src/random.h
index 46e3ecc34c..690125079b 100644
--- a/src/random.h
+++ b/src/random.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2019 The Bitcoin Core developers
+// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -104,7 +104,8 @@ void RandAddEvent(const uint32_t event_info) noexcept;
*
* This class is not thread-safe.
*/
-class FastRandomContext {
+class FastRandomContext
+{
private:
bool requires_seed;
ChaCha20 rng;
@@ -156,7 +157,8 @@ public:
}
/** Generate a random (bits)-bit integer. */
- uint64_t randbits(int bits) noexcept {
+ uint64_t randbits(int bits) noexcept
+ {
if (bits == 0) {
return 0;
} else if (bits > 32) {
@@ -170,7 +172,9 @@ public:
}
}
- /** Generate a random integer in the range [0..range). */
+ /** Generate a random integer in the range [0..range).
+ * Precondition: range > 0.
+ */
uint64_t randrange(uint64_t range) noexcept
{
assert(range);
@@ -211,7 +215,7 @@ public:
* debug mode detects and panics on. This is a known issue, see
* https://stackoverflow.com/questions/22915325/avoiding-self-assignment-in-stdshuffle
*/
-template<typename I, typename R>
+template <typename I, typename R>
void Shuffle(I first, I last, R&& rng)
{
while (first != last) {
@@ -234,7 +238,7 @@ static const int NUM_OS_RANDOM_BYTES = 32;
/** Get 32 bytes of system entropy. Do not use this in application code: use
* GetStrongRandBytes instead.
*/
-void GetOSRand(unsigned char *ent32);
+void GetOSRand(unsigned char* ent32);
/** Check that OS randomness is available and returning the requested number
* of bytes.