From bcc2625406943528238dcf34ae88fda2edc81c45 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Wed, 23 Aug 2017 17:19:19 -0500 Subject: [PATCH] Moving random_pool to a different location and static objects don't reference it. --- rai/secure.cpp | 7 +++---- rai/utility.cpp | 2 ++ rai/utility.hpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rai/secure.cpp b/rai/secure.cpp index 516082a4..71eac76b 100755 --- a/rai/secure.cpp +++ b/rai/secure.cpp @@ -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 ::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); diff --git a/rai/utility.cpp b/rai/utility.cpp index 25507d35..b860656c 100644 --- a/rai/utility.cpp +++ b/rai/utility.cpp @@ -7,6 +7,8 @@ #include +thread_local CryptoPP::AutoSeededRandomPool rai::random_pool; + boost::filesystem::path rai::unique_path () { auto result (working_path () / boost::filesystem::unique_path ()); diff --git a/rai/utility.hpp b/rai/utility.hpp index b6e7cb3e..f6a71821 100755 --- a/rai/utility.hpp +++ b/rai/utility.hpp @@ -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 ; using bufferstream = boost::iostreams::stream_buffer >;