Browse Source

Merge branch 'rngfix' into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
abaf9e9b0f
  1. 6
      libdevcore/CommonData.cpp
  2. 3
      libdevcore/FixedHash.h
  3. 3
      libdevcore/vector_ref.h
  4. 3
      libethash-cl/ethash_cl_miner.cpp

6
libdevcore/CommonData.cpp

@ -20,7 +20,7 @@
*/
#include "CommonData.h"
#include <boost/random/uniform_int_distribution.hpp>
#include "Exceptions.h"
#include "Log.h"
@ -58,9 +58,9 @@ std::string dev::escaped(std::string const& _s, bool _all)
std::string dev::randomWord()
{
static std::mt19937_64 s_eng(0);
std::string ret(std::uniform_int_distribution<int>(1, 5)(s_eng), ' ');
std::string ret(boost::random::uniform_int_distribution<int>(1, 5)(s_eng), ' ');
char const n[] = "qwertyuiop";//asdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
std::uniform_int_distribution<int> d(0, sizeof(n) - 2);
boost::random::uniform_int_distribution<int> d(0, sizeof(n) - 2);
for (char& c: ret)
c = n[d(s_eng)];
return ret;

3
libdevcore/FixedHash.h

@ -27,6 +27,7 @@
#include <cstdint>
#include <algorithm>
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include "CommonData.h"
namespace dev
@ -154,7 +155,7 @@ public:
{
FixedHash ret;
for (auto& i: ret.m_data)
i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng);
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
return ret;
}

3
libdevcore/vector_ref.h

@ -7,6 +7,7 @@
#include <string>
#include <random>
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
namespace dev
{
@ -76,7 +77,7 @@ public:
{
uint8_t* e = (uint8_t*)end();
for (uint8_t* i = (uint8_t*)begin(); i != e; ++i)
*i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng);
*i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
}
/// @returns a random valued object.
void randomize() { randomize(s_vectorRefEngine); }

3
libethash-cl/ethash_cl_miner.cpp

@ -32,6 +32,7 @@
#include <vector>
#include <random>
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <libethash/util.h>
#include <libethash/ethash.h>
#include <libethash/internal.h>
@ -472,7 +473,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
unsigned buf = 0;
boost::random_device engine;
uint64_t start_nonce = uniform_int_distribution<uint64_t>()(engine);
uint64_t start_nonce = boost::random::uniform_int_distribution<uint64_t>()(engine);
for (;; start_nonce += m_globalWorkSize)
{
auto t = chrono::high_resolution_clock::now();

Loading…
Cancel
Save