Browse Source

Remove boost::random

cl-refactor
Paweł Bylica 8 years ago
parent
commit
0f8445ad11
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 2
      cmake/EthDependencies.cmake
  2. 24
      libdevcore/FixedHash.cpp
  3. 8
      libdevcore/FixedHash.h

2
cmake/EthDependencies.cmake

@ -93,7 +93,7 @@ elseif (UNIX)
endif()
find_package(Boost 1.54.0 REQUIRED COMPONENTS random)
find_package(Boost 1.54.0 REQUIRED COMPONENTS system)
message(" - boost header: ${Boost_INCLUDE_DIRS}")
message(" - boost lib : ${Boost_LIBRARIES}")

24
libdevcore/FixedHash.cpp

@ -20,31 +20,9 @@
*/
#include "FixedHash.h"
#include <ctime>
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace dev;
boost::random_device dev::s_fixedHashEngine;
h128 dev::fromUUID(std::string const& _uuid)
{
try
{
return h128(boost::replace_all_copy(_uuid, "-", ""));
}
catch (...)
{
return h128();
}
}
std::string dev::toUUID(h128 const& _uuid)
{
std::string ret = toHex(_uuid.ref());
for (unsigned i: {20, 16, 12, 8})
ret.insert(ret.begin() + i, '-');
return ret;
}
std::random_device dev::s_fixedHashEngine;

8
libdevcore/FixedHash.h

@ -26,8 +26,7 @@
#include <array>
#include <cstdint>
#include <algorithm>
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <random>
#include "CommonData.h"
namespace dev
@ -37,7 +36,7 @@ namespace dev
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; };
template <> struct StaticLog2<1> { enum { result = 0 }; };
extern boost::random_device s_fixedHashEngine;
extern std::random_device s_fixedHashEngine;
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
/// Transparently converts to/from the corresponding arithmetic type; this will
@ -154,7 +153,7 @@ public:
void randomize(Engine& _eng)
{
for (auto& i: m_data)
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng);
}
/// @returns a random valued object.
@ -291,7 +290,6 @@ public:
bytesConstRef ref() const { return FixedHash<T>::ref(); }
byte const* data() const { return FixedHash<T>::data(); }
static SecureFixedHash<T> random() { SecureFixedHash<T> ret; ret.randomize(s_fixedHashEngine); return ret; }
using FixedHash<T>::firstBitSet;
void clear() { ref().cleanse(); }

Loading…
Cancel
Save