Moving random_pool to a different location and static objects don't reference it.

This commit is contained in:
clemahieu 2017-08-23 17:19:19 -05:00
commit bcc2625406
3 changed files with 6 additions and 5 deletions

View file

@ -61,9 +61,10 @@ genesis_account (rai::rai_network == rai::rai_networks::rai_test_network ? rai_t
genesis_block (rai::rai_network == rai::rai_networks::rai_test_network ? rai_test_genesis : rai::rai_network == rai::rai_networks::rai_beta_network ? rai_beta_genesis : rai_live_genesis),
genesis_amount (std::numeric_limits <rai::uint128_t>::max ())
{
CryptoPP::AutoSeededRandomPool random_pool;
// Randomly generating these mean no two nodes will ever have the same sentinal values which protects against some insecure algorithms
rai::random_pool.GenerateBlock (not_a_block.bytes.data (), not_a_block.bytes.size ());
rai::random_pool.GenerateBlock (not_an_account.bytes.data (), not_an_account.bytes.size ());
random_pool.GenerateBlock (not_a_block.bytes.data (), not_a_block.bytes.size ());
random_pool.GenerateBlock (not_an_account.bytes.data (), not_an_account.bytes.size ());
}
rai::keypair zero_key;
rai::keypair test_genesis_key;
@ -76,7 +77,6 @@ std::string rai_live_genesis;
rai::account genesis_account;
std::string genesis_block;
rai::uint128_t genesis_amount;
CryptoPP::AutoSeededRandomPool random_pool;
rai::block_hash not_a_block;
rai::account not_an_account;
};
@ -100,7 +100,6 @@ std::string const & rai::rai_live_genesis (globals.rai_live_genesis);
rai::account const & rai::genesis_account (globals.genesis_account);
std::string const & rai::genesis_block (globals.genesis_block);
rai::uint128_t const & rai::genesis_amount (globals.genesis_amount);
thread_local CryptoPP::AutoSeededRandomPool & rai::random_pool (globals.random_pool);
rai::block_hash const & rai::not_a_block (globals.not_a_block);
rai::block_hash const & rai::not_an_account (globals.not_an_account);

View file

@ -7,6 +7,8 @@
#include <lmdb/libraries/liblmdb/lmdb.h>
thread_local CryptoPP::AutoSeededRandomPool rai::random_pool;
boost::filesystem::path rai::unique_path ()
{
auto result (working_path () / boost::filesystem::unique_path ());

View file

@ -23,7 +23,7 @@ namespace rai
{
// Random pool used by RaiBlocks.
// This must be thread_local as long as the AutoSeededRandomPool implementation requires it
extern thread_local CryptoPP::AutoSeededRandomPool & random_pool;
extern thread_local CryptoPP::AutoSeededRandomPool random_pool;
// We operate on streams of uint8_t by convention
using stream = std::basic_streambuf <uint8_t>;
using bufferstream = boost::iostreams::stream_buffer <boost::iostreams::basic_array_source <uint8_t>>;