Add UpdatedBlockTip signal to CMainSignals and CValidationInterface
[bitcoinplatinum.git] / src / random.h
blob1a2d3e8ee24ca623fd622bd897295c0b5a65d770
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_RANDOM_H
7 #define BITCOIN_RANDOM_H
9 #include "uint256.h"
11 #include <stdint.h>
13 /**
14 * Seed OpenSSL PRNG with additional entropy data
16 void RandAddSeed();
17 void RandAddSeedPerfmon();
19 /**
20 * Functions to gather random data via the OpenSSL PRNG
22 void GetRandBytes(unsigned char* buf, int num);
23 uint64_t GetRand(uint64_t nMax);
24 int GetRandInt(int nMax);
25 uint256 GetRandHash();
27 /**
28 * Seed insecure_rand using the random pool.
29 * @param Deterministic Use a deterministic seed
31 void seed_insecure_rand(bool fDeterministic = false);
33 /**
34 * MWC RNG of George Marsaglia
35 * This is intended to be fast. It has a period of 2^59.3, though the
36 * least significant 16 bits only have a period of about 2^30.1.
38 * @return random value
40 extern uint32_t insecure_rand_Rz;
41 extern uint32_t insecure_rand_Rw;
42 static inline uint32_t insecure_rand(void)
44 insecure_rand_Rz = 36969 * (insecure_rand_Rz & 65535) + (insecure_rand_Rz >> 16);
45 insecure_rand_Rw = 18000 * (insecure_rand_Rw & 65535) + (insecure_rand_Rw >> 16);
46 return (insecure_rand_Rw << 16) + insecure_rand_Rz;
49 #endif // BITCOIN_RANDOM_H