2016-10-13 16:19:20 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2016-12-31 11:01:21 -07:00
|
|
|
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
2016-10-13 16:19:20 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_TEST_RANDOM_H
|
|
|
|
#define BITCOIN_TEST_RANDOM_H
|
|
|
|
|
|
|
|
#include "random.h"
|
|
|
|
|
2017-02-15 17:45:22 -08:00
|
|
|
extern uint256 insecure_rand_seed;
|
2016-10-13 16:19:20 +02:00
|
|
|
extern FastRandomContext insecure_rand_ctx;
|
|
|
|
|
|
|
|
static inline void seed_insecure_rand(bool fDeterministic = false)
|
|
|
|
{
|
2017-02-15 17:45:22 -08:00
|
|
|
if (fDeterministic) {
|
|
|
|
insecure_rand_seed = uint256();
|
|
|
|
} else {
|
|
|
|
insecure_rand_seed = GetRandHash();
|
|
|
|
}
|
|
|
|
insecure_rand_ctx = FastRandomContext(insecure_rand_seed);
|
2016-10-13 16:19:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t insecure_rand(void)
|
|
|
|
{
|
|
|
|
return insecure_rand_ctx.rand32();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|