Browse Source

Merge remote-tracking branch 'origin/master' into release/0.11

master
Paweł Bylica 8 years ago
parent
commit
e5b97c7b0a
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 32
      ethminer/MinerAux.h
  2. 110
      libdevcore/Assertions.h
  3. 17
      libdevcore/Exceptions.h
  4. 176
      libdevcore/FixedHash.h
  5. 12
      libdevcore/Guards.h
  6. 22
      libdevcore/Log.cpp
  7. 7
      libdevcore/Log.h
  8. 13
      libdevcore/RLP.cpp
  9. 54
      libdevcore/RLP.h
  10. 4
      libdevcore/SHA3.cpp
  11. 2
      libdevcore/SHA3.h
  12. 17
      libethash-cuda/CMakeLists.txt
  13. 5
      libethcore/Miner.h
  14. 4
      libstratum/EthStratumClient.cpp
  15. 4
      libstratum/EthStratumClientV2.cpp

32
ethminer/MinerAux.h

@ -81,7 +81,6 @@ public:
enum class OperationMode
{
None,
DAGInit,
Benchmark,
Simulation,
Farm,
@ -380,8 +379,6 @@ public:
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
else if (arg == "-C" || arg == "--cpu")
m_minerType = MinerType::CPU;
else if (arg == "-G" || arg == "--opencl")
m_minerType = MinerType::CL;
else if (arg == "-U" || arg == "--cuda")
@ -464,17 +461,10 @@ public:
if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
EthashCUDAMiner::listDevices();
#endif
if (m_minerType == MinerType::CPU)
cout << "--list-devices should be combined with GPU mining flag (-G for OpenCL or -U for CUDA)" << endl;
exit(0);
}
if (m_minerType == MinerType::CPU)
{
cout << "CPU mining is no longer supported in this miner. Use -G (opencl) or -U (cuda) flag to select GPU platform." << endl;
exit(0);
}
else if (m_minerType == MinerType::CL || m_minerType == MinerType::Mixed)
if (m_minerType == MinerType::CL || m_minerType == MinerType::Mixed)
{
#if ETH_ETHASHCL
if (m_openclDeviceCount > 0)
@ -605,8 +595,6 @@ public:
;
}
MinerType minerType() const { return m_minerType; }
private:
void doBenchmark(MinerType _m, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5)
@ -627,7 +615,7 @@ private:
f.setSealers(sealers);
f.onSolutionFound([&](Solution) { return false; });
string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "CL" : "CUDA");
string platformInfo = _m == MinerType::CL ? "CL" : "CUDA";
cout << "Benchmarking on platform: " << platformInfo << endl;
cout << "Preparing DAG for block #" << m_benchmarkBlock << endl;
@ -635,9 +623,7 @@ private:
genesis.setDifficulty(u256(1) << 63);
f.setWork(genesis);
if (_m == MinerType::CPU)
f.start("cpu", false);
else if (_m == MinerType::CL)
if (_m == MinerType::CL)
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda", false);
@ -692,7 +678,7 @@ private:
#endif
f.setSealers(sealers);
string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "CL" : "CUDA");
string platformInfo = _m == MinerType::CL ? "CL" : "CUDA";
cout << "Running mining simulation on platform: " << platformInfo << endl;
cout << "Preparing DAG for block #" << m_benchmarkBlock << endl;
@ -701,9 +687,7 @@ private:
genesis.setDifficulty(u256(1) << difficulty);
f.setWork(genesis);
if (_m == MinerType::CPU)
f.start("cpu", false);
else if (_m == MinerType::CL)
if (_m == MinerType::CL)
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda", false);
@ -782,9 +766,7 @@ private:
h256 id = h256::random();
Farm f;
f.setSealers(sealers);
if (_m == MinerType::CPU)
f.start("cpu", false);
else if (_m == MinerType::CL)
if (_m == MinerType::CL)
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda", false);
@ -1019,7 +1001,7 @@ private:
/// Mining options
bool m_running = true;
MinerType m_minerType = MinerType::CPU;
MinerType m_minerType = MinerType::Mixed;
unsigned m_openclPlatform = 0;
unsigned m_openclDevice = 0;
unsigned m_miningThreads = UINT_MAX;

110
libdevcore/Assertions.h

@ -1,110 +0,0 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file Assertions.h
* @author Christian <c@ethdev.com>
* @date 2015
*
* Assertion handling.
*/
#pragma once
#include "Exceptions.h"
namespace dev
{
#if defined(_MSC_VER)
#define ETH_FUNC __FUNCSIG__
#elif defined(__GNUC__)
#define ETH_FUNC __PRETTY_FUNCTION__
#else
#define ETH_FUNC __func__
#endif
#define asserts(A) ::dev::assertAux(A, #A, __LINE__, __FILE__, ETH_FUNC)
#define assertsEqual(A, B) ::dev::assertEqualAux(A, B, #A, #B, __LINE__, __FILE__, ETH_FUNC)
inline bool assertAux(bool _a, char const* _aStr, unsigned _line, char const* _file, char const* _func)
{
bool ret = _a;
if (!ret)
{
std::cerr << "Assertion failed:" << _aStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
#if ETH_DEBUG
debug_break();
#endif
}
return !ret;
}
template<class A, class B>
inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char const* _bStr, unsigned _line, char const* _file, char const* _func)
{
bool ret = _a == _b;
if (!ret)
{
std::cerr << "Assertion failed: " << _aStr << " == " << _bStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
std::cerr << " Fail equality: " << _a << "==" << _b << std::endl;
#if ETH_DEBUG
debug_break();
#endif
}
return !ret;
}
/// Assertion that throws an exception containing the given description if it is not met.
/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
/// Do NOT supply an exception object as the second parameter.
#define assertThrow(_condition, _ExceptionType, _description) \
::dev::assertThrowAux<_ExceptionType>(_condition, _description, __LINE__, __FILE__, ETH_FUNC)
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
template <class _ExceptionType>
inline void assertThrowAux(
bool _condition,
::std::string const& _errorDescription,
unsigned _line,
char const* _file,
char const* _function
)
{
if (!_condition)
::boost::throw_exception(
_ExceptionType() <<
::dev::errinfo_comment(_errorDescription) <<
::boost::throw_function(_function) <<
::boost::throw_file(_file) <<
::boost::throw_line(_line)
);
}
template <class _ExceptionType>
inline void assertThrowAux(
void const* _pointer,
::std::string const& _errorDescription,
unsigned _line,
char const* _file,
char const* _function
)
{
assertThrowAux<_ExceptionType>(_pointer != nullptr, _errorDescription, _line, _file, _function);
}
}

17
libdevcore/Exceptions.h

@ -53,31 +53,14 @@ DEV_SIMPLE_EXCEPTION_RLP(OversizeRLP);
DEV_SIMPLE_EXCEPTION_RLP(UndersizeRLP);
DEV_SIMPLE_EXCEPTION(BadHexCharacter);
DEV_SIMPLE_EXCEPTION(NoNetworking);
DEV_SIMPLE_EXCEPTION(NoUPnPDevice);
DEV_SIMPLE_EXCEPTION(RootNotFound);
struct BadRoot: virtual Exception { public: BadRoot(h256 const& _root): Exception("BadRoot " + _root.hex()), root(_root) {} h256 root; };
DEV_SIMPLE_EXCEPTION(FileError);
DEV_SIMPLE_EXCEPTION(Overflow);
DEV_SIMPLE_EXCEPTION(FailedInvariant);
DEV_SIMPLE_EXCEPTION(ValueTooLarge);
struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): Exception("Interface " + _f + " not supported.") {} };
struct ExternalFunctionFailure: virtual Exception { public: ExternalFunctionFailure(std::string _f): Exception("Function " + _f + "() failed.") {} };
// error information to be added to exceptions
using errinfo_invalidSymbol = boost::error_info<struct tag_invalidSymbol, char>;
using errinfo_wrongAddress = boost::error_info<struct tag_address, std::string>;
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
using errinfo_required = boost::error_info<struct tag_required, bigint>;
using errinfo_got = boost::error_info<struct tag_got, bigint>;
using errinfo_min = boost::error_info<struct tag_min, bigint>;
using errinfo_max = boost::error_info<struct tag_max, bigint>;
using RequirementError = boost::tuple<errinfo_required, errinfo_got>;
using errinfo_hash256 = boost::error_info<struct tag_hash, h256>;
using errinfo_required_h256 = boost::error_info<struct tag_required_h256, h256>;
using errinfo_got_h256 = boost::error_info<struct tag_get_h256, h256>;
using Hash256RequirementError = boost::tuple<errinfo_required_h256, errinfo_got_h256>;
using errinfo_extraData = boost::error_info<struct tag_extraData, bytes>;
}

176
libdevcore/FixedHash.h

@ -32,10 +32,6 @@
namespace dev
{
/// Compile-time calculation of Log2 of constant values.
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; };
template <> struct StaticLog2<1> { enum { result = 0 }; };
extern std::random_device s_fixedHashEngine;
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
@ -54,9 +50,6 @@ public:
/// A dummy flag to avoid accidental construction from pointer.
enum ConstructFromPointerType { ConstructFromPointer };
/// Method to convert from a string.
enum ConstructFromStringType { FromHex, FromBinary };
/// Method to convert from a string.
enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent };
@ -82,7 +75,7 @@ public:
explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); }
/// Explicitly construct, copying from a string.
explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : dev::asBytes(_s), _ht) {}
explicit FixedHash(std::string const& _s): FixedHash(fromHex(_s, WhenError::Throw), FailIfDifferent) {}
/// Convert to arithmetic type.
operator Arith() const { return fromBigEndian<Arith>(m_data); }
@ -110,9 +103,6 @@ public:
// Big-endian increment.
FixedHash& operator++() { for (unsigned i = size; i > 0 && !++m_data[--i]; ) {} return *this; }
/// @returns true if all one-bits in @a _c are set in this object.
bool contains(FixedHash const& _c) const { return (*this & _c) == _c; }
/// @returns a particular byte from the hash.
byte& operator[](unsigned _i) { return m_data[_i]; }
/// @returns a particular byte from the hash.
@ -121,9 +111,6 @@ public:
/// @returns an abridged version of the hash as a user-readable hex string.
std::string abridged() const { return toHex(ref().cropped(0, 4)) + "\342\200\246"; }
/// @returns a version of the hash as a user-readable hex string that leaves out the middle part.
std::string abridgedMiddle() const { return toHex(ref().cropped(0, 4)) + "\342\200\246" + toHex(ref().cropped(N - 4)); }
/// @returns the hash as a user-readable hex string.
std::string hex() const { return toHex(ref()); }
@ -139,15 +126,6 @@ public:
/// @returns a constant byte pointer to the object's data.
byte const* data() const { return m_data.data(); }
/// @returns a copy of the object's data as a byte vector.
bytes asBytes() const { return bytes(data(), data() + N); }
/// @returns a mutable reference to the object's data as an STL array.
std::array<byte, N>& asArray() { return m_data; }
/// @returns a constant reference to the object's data as an STL array.
std::array<byte, N> const& asArray() const { return m_data; }
/// Populate with random data.
template <class Engine>
void randomize(Engine& _eng)
@ -165,136 +143,12 @@ public:
size_t operator()(FixedHash const& _value) const { return boost::hash_range(_value.m_data.cbegin(), _value.m_data.cend()); }
};
template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h)
{
return (*this |= _h.template bloomPart<P, N>());
}
template <unsigned P, unsigned M> inline bool containsBloom(FixedHash<M> const& _h)
{
return contains(_h.template bloomPart<P, N>());
}
template <unsigned P, unsigned M> inline FixedHash<M> bloomPart() const
{
unsigned const c_bloomBits = M * 8;
unsigned const c_mask = c_bloomBits - 1;
unsigned const c_bloomBytes = (StaticLog2<c_bloomBits>::result + 7) / 8;
static_assert((M & (M - 1)) == 0, "M must be power-of-two");
static_assert(P * c_bloomBytes <= N, "out of range");
FixedHash<M> ret;
byte const* p = data();
for (unsigned i = 0; i < P; ++i)
{
unsigned index = 0;
for (unsigned j = 0; j < c_bloomBytes; ++j, ++p)
index = (index << 8) | *p;
index &= c_mask;
ret[M - 1 - index / 8] |= (1 << (index % 8));
}
return ret;
}
/// Returns the index of the first bit set to one, or size() * 8 if no bits are set.
inline unsigned firstBitSet() const
{
unsigned ret = 0;
for (auto d: m_data)
if (d)
for (;; ++ret, d <<= 1)
if (d & 0x80)
return ret;
else {}
else
ret += 8;
return ret;
}
void clear() { m_data.fill(0); }
private:
std::array<byte, N> m_data; ///< The binary data.
};
template <unsigned T>
class SecureFixedHash: private FixedHash<T>
{
public:
using ConstructFromHashType = typename FixedHash<T>::ConstructFromHashType;
using ConstructFromStringType = typename FixedHash<T>::ConstructFromStringType;
using ConstructFromPointerType = typename FixedHash<T>::ConstructFromPointerType;
SecureFixedHash() = default;
explicit SecureFixedHash(bytes const& _b, ConstructFromHashType _t = FixedHash<T>::FailIfDifferent): FixedHash<T>(_b, _t) {}
explicit SecureFixedHash(bytesConstRef _b, ConstructFromHashType _t = FixedHash<T>::FailIfDifferent): FixedHash<T>(_b, _t) {}
explicit SecureFixedHash(bytesSec const& _b, ConstructFromHashType _t = FixedHash<T>::FailIfDifferent): FixedHash<T>(_b.ref(), _t) {}
template <unsigned M> explicit SecureFixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = FixedHash<T>::AlignLeft): FixedHash<T>(_h, _t) {}
template <unsigned M> explicit SecureFixedHash(SecureFixedHash<M> const& _h, ConstructFromHashType _t = FixedHash<T>::AlignLeft): FixedHash<T>(_h.makeInsecure(), _t) {}
explicit SecureFixedHash(std::string const& _s, ConstructFromStringType _t = FixedHash<T>::FromHex, ConstructFromHashType _ht = FixedHash<T>::FailIfDifferent): FixedHash<T>(_s, _t, _ht) {}
explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash<T>(_d, _t) {}
~SecureFixedHash() { ref().cleanse(); }
SecureFixedHash<T>& operator=(SecureFixedHash<T> const& _c)
{
if (&_c == this)
return *this;
ref().cleanse();
FixedHash<T>::operator=(static_cast<FixedHash<T> const&>(_c));
return *this;
}
using FixedHash<T>::size;
bytesSec asBytesSec() const { return bytesSec(ref()); }
FixedHash<T> const& makeInsecure() const { return static_cast<FixedHash<T> const&>(*this); }
FixedHash<T>& writable() { clear(); return static_cast<FixedHash<T>&>(*this); }
using FixedHash<T>::operator bool;
// The obvious comparison operators.
bool operator==(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator==(static_cast<FixedHash<T> const&>(_c)); }
bool operator!=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator!=(static_cast<FixedHash<T> const&>(_c)); }
bool operator<(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator<(static_cast<FixedHash<T> const&>(_c)); }
bool operator>=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator>=(static_cast<FixedHash<T> const&>(_c)); }
bool operator<=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator<=(static_cast<FixedHash<T> const&>(_c)); }
bool operator>(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator>(static_cast<FixedHash<T> const&>(_c)); }
using FixedHash<T>::operator==;
using FixedHash<T>::operator!=;
using FixedHash<T>::operator<;
using FixedHash<T>::operator>=;
using FixedHash<T>::operator<=;
using FixedHash<T>::operator>;
// The obvious binary operators.
SecureFixedHash& operator^=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
SecureFixedHash operator^(FixedHash<T> const& _c) const { return SecureFixedHash(*this) ^= _c; }
SecureFixedHash& operator|=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
SecureFixedHash operator|(FixedHash<T> const& _c) const { return SecureFixedHash(*this) |= _c; }
SecureFixedHash& operator&=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
SecureFixedHash operator&(FixedHash<T> const& _c) const { return SecureFixedHash(*this) &= _c; }
SecureFixedHash& operator^=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
SecureFixedHash operator^(SecureFixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; }
SecureFixedHash& operator|=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
SecureFixedHash operator|(SecureFixedHash const& _c) const { return SecureFixedHash(*this) |= _c; }
SecureFixedHash& operator&=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
SecureFixedHash operator&(SecureFixedHash const& _c) const { return SecureFixedHash(*this) &= _c; }
SecureFixedHash operator~() const { auto r = ~static_cast<FixedHash<T> const&>(*this); return static_cast<SecureFixedHash const&>(r); }
using FixedHash<T>::abridged;
using FixedHash<T>::abridgedMiddle;
bytesConstRef ref() const { return FixedHash<T>::ref(); }
byte const* data() const { return FixedHash<T>::data(); }
using FixedHash<T>::firstBitSet;
void clear() { ref().cleanse(); }
};
/// Fast equality operator for h256.
template<> inline bool FixedHash<32>::operator==(FixedHash<32> const& _other) const
{
@ -321,14 +175,6 @@ inline std::ostream& operator<<(std::ostream& _out, FixedHash<N> const& _h)
return _out;
}
/// Stream I/O for the SecureFixedHash class.
template <unsigned N>
inline std::ostream& operator<<(std::ostream& _out, SecureFixedHash<N> const& _h)
{
_out << "SecureFixedHash#" << std::hex << typename FixedHash<N>::hash()(_h.makeInsecure()) << std::dec;
return _out;
}
// Common types of FixedHash.
using h2048 = FixedHash<256>;
using h1024 = FixedHash<128>;
@ -346,26 +192,6 @@ using h160Set = std::set<h160>;
using h256Hash = std::unordered_set<h256>;
using h160Hash = std::unordered_set<h160>;
/// Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.
inline h160 right160(h256 const& _t)
{
h160 ret;
memcpy(ret.data(), _t.data() + 12, 20);
return ret;
}
/// Convert the given value into h160 (160-bit unsigned integer) using the left 20 bytes.
inline h160 left160(h256 const& _t)
{
h160 ret;
memcpy(&ret[0], _t.data(), 20);
return ret;
}
h128 fromUUID(std::string const& _uuid);
std::string toUUID(h128 const& _uuid);
inline std::string toString(h256s const& _bs)
{
std::ostringstream out;

12
libdevcore/Guards.h

@ -39,18 +39,6 @@ struct GenericGuardBool: GuardType
bool b = true;
};
/** @brief Simple lock that waits for release without making context switch */
class SpinLock
{
public:
SpinLock() { m_lock.clear(); }
void lock() { while (m_lock.test_and_set(std::memory_order_acquire)) {} }
void unlock() { m_lock.clear(std::memory_order_release); }
private:
std::atomic_flag m_lock;
};
using SpinGuard = std::lock_guard<SpinLock>;
template <class N>
class Notified
{

22
libdevcore/Log.cpp

@ -130,11 +130,6 @@ string dev::ThreadContext::join(string const& _prior)
return g_logThreadContext.join(_prior);
}
// foward declare without all of Windows.h
#ifdef _WIN32
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
#endif
string dev::getThreadName()
{
#if defined(__linux__) || defined(__APPLE__)
@ -158,20 +153,7 @@ void dev::setThreadName(char const* _n)
#endif
}
void dev::simpleDebugOut(std::string const& _s, char const*)
void dev::simpleDebugOut(std::string const& _s)
{
static SpinLock s_lock;
SpinGuard l(s_lock);
cerr << _s << endl << flush;
// helpful to use OutputDebugString on windows
#ifdef _WIN32
{
OutputDebugStringA(_s.data());
OutputDebugStringA("\n");
}
#endif
std::cerr << _s << '\n';
}
std::function<void(std::string const&, char const*)> dev::g_logPost = simpleDebugOut;

7
libdevcore/Log.h

@ -44,14 +44,11 @@ public:
};
/// A simple log-output function that prints log messages to stdout.
void simpleDebugOut(std::string const&, char const*);
void simpleDebugOut(std::string const&);
/// The logging system's current verbosity.
extern int g_logVerbosity;
/// The current method that the logging system uses to output the log messages. Defaults to simpleDebugOut().
extern std::function<void(std::string const&, char const*)> g_logPost;
class ThreadContext
{
public:
@ -208,7 +205,7 @@ public:
LogOutputStream(): LogOutputStreamBase(Id::name(), &typeid(Id), Id::verbosity, _AutoSpacing) {}
/// Destructor. Posts the accrued log entry to the g_logPost function.
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(m_sstr.str(), Id::name()); }
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) simpleDebugOut(m_sstr.str()); }
LogOutputStream& operator<<(std::string const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; comment(_t); } return *this; }

13
libdevcore/RLP.cpp

@ -23,9 +23,6 @@
using namespace std;
using namespace dev;
bytes dev::RLPNull = rlp("");
bytes dev::RLPEmptyList = rlpList();
RLP::RLP(bytesConstRef _d, Strictness _s):
m_data(_d)
{
@ -131,7 +128,7 @@ bool RLP::isInt() const
requireGood();
byte n = m_data[0];
if (n < c_rlpDataImmLenStart)
return !!n;
return n != 0;
else if (n == c_rlpDataImmLenStart)
return true;
else if (n <= c_rlpDataIndLenZero)
@ -146,8 +143,6 @@ bool RLP::isInt() const
BOOST_THROW_EXCEPTION(BadRLP());
return m_data[1 + n - c_rlpDataIndLenZero] != 0;
}
else
return false;
return false;
}
@ -365,9 +360,3 @@ static void streamOut(std::ostream& _out, dev::RLP const& _d, unsigned _depth =
_out << " ]";
}
}
std::ostream& dev::operator<<(std::ostream& _out, RLP const& _d)
{
streamOut(_out, _d);
return _out;
}

54
libdevcore/RLP.h

@ -100,9 +100,6 @@ public:
/// No value.
bool isNull() const { return m_data.size() == 0; }
/// Contains a zero-length string or zero-length list.
bool isEmpty() const { return !isNull() && (m_data[0] == c_rlpDataImmLenStart || m_data[0] == c_rlpListStart); }
/// String value.
bool isData() const { return !isNull() && m_data[0] < c_rlpListStart; }
@ -118,7 +115,6 @@ public:
/// @returns the number of bytes in the data, or zero if it isn't data.
size_t size() const { return isData() ? length() : 0; }
size_t sizeStrict() const { if (!isData()) BOOST_THROW_EXCEPTION(BadCast()); return length(); }
/// Equality operators; does best-effort conversion and checks for equality.
bool operator==(char const* _s) const { return isData() && toString() == _s; }
@ -189,12 +185,8 @@ public:
/// Converts to bytearray. @returns the empty byte array if not a string.
bytes toBytes() const { if (!isData()) return bytes(); return bytes(payload().data(), payload().data() + length()); }
/// Converts to bytearray. @returns the empty byte array if not a string.
bytesConstRef toBytesConstRef() const { if (!isData()) return bytesConstRef(); return payload().cropped(0, length()); }
/// Converts to string. @returns the empty string if not a string.
std::string toString() const { if (!isData()) return std::string(); return payload().cropped(0, length()).toString(); }
/// Converts to string. @throws BadCast if not a string.
std::string toStringStrict() const { if (!isData()) BOOST_THROW_EXCEPTION(BadCast()); return payload().cropped(0, length()).toString(); }
template <class T>
std::vector<T> toVector() const
@ -219,16 +211,6 @@ public:
return ret;
}
template <class T>
std::unordered_set<T> toUnorderedSet() const
{
std::unordered_set<T> ret;
if (isList())
for (auto const& i: *this)
ret.insert((T)i);
return ret;
}
template <class T, class U>
std::pair<T, U> toPair() const
{
@ -369,20 +351,14 @@ public:
/// Appends a sequence of data to the stream as a list.
template <class _T> RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); }
template <class _T> RLPStream& appendVector(std::vector<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
template <class _T, size_t S> RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
template <class _T> RLPStream& append(std::set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
template <class _T> RLPStream& append(std::unordered_set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
template <class T, class U> RLPStream& append(std::pair<T, U> const& _s) { appendList(2); append(_s.first); append(_s.second); return *this; }
/// Appends a list.
RLPStream& appendList(size_t _items);
RLPStream& appendList(bytesConstRef _rlp);
RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); }
RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); }
/// Appends raw (pre-serialised) RLP data. Use with caution.
RLPStream& appendRaw(bytesConstRef _rlp, size_t _itemCount = 1);
RLPStream& appendRaw(bytes const& _rlp, size_t _itemCount = 1) { return appendRaw(&_rlp, _itemCount); }
/// Shift operators for appending data items.
template <class T> RLPStream& operator<<(T _data) { return append(_data); }
@ -393,12 +369,6 @@ public:
/// Read the byte stream.
bytes const& out() const { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return m_out; }
/// Invalidate the object and steal the output byte stream.
bytes&& invalidate() { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return std::move(m_out); }
/// Swap the contents of the output stream out for some other byte array.
void swapOut(bytes& _dest) { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); swap(m_out, _dest); }
private:
void noteAppended(size_t _itemCount = 1);
@ -421,28 +391,4 @@ private:
std::vector<std::pair<size_t, size_t>> m_listStack;
};
template <class _T> void rlpListAux(RLPStream& _out, _T _t) { _out << _t; }
template <class _T, class ... _Ts> void rlpListAux(RLPStream& _out, _T _t, _Ts ... _ts) { rlpListAux(_out << _t, _ts...); }
/// Export a single item in RLP format, returning a byte array.
template <class _T> bytes rlp(_T _t) { return (RLPStream() << _t).out(); }
/// Export a list of items in RLP format, returning a byte array.
inline bytes rlpList() { return RLPStream(0).out(); }
template <class ... _Ts> bytes rlpList(_Ts ... _ts)
{
RLPStream out(sizeof ...(_Ts));
rlpListAux(out, _ts...);
return out.out();
}
/// The empty string in RLP format.
extern bytes RLPNull;
/// The empty list in RLP format.
extern bytes RLPEmptyList;
/// Human readable version of RLP.
std::ostream& operator<<(std::ostream& _out, dev::RLP const& _d);
}

4
libdevcore/SHA3.cpp

@ -20,15 +20,13 @@
*/
#include "SHA3.h"
#include "RLP.h"
using namespace std;
using namespace dev;
namespace dev
{
h256 EmptyListSHA3 = sha3(rlpList());
namespace keccak
{

2
libdevcore/SHA3.h

@ -45,6 +45,4 @@ inline h256 sha3(bytes const& _input) { return sha3(bytesConstRef(&_input)); }
/// Calculate SHA3-256 hash of the given input (presented as a FixedHash), returns a 256-bit hash.
template<unsigned N> inline h256 sha3(FixedHash<N> const& _input) { return sha3(_input.ref()); }
extern h256 EmptyListSHA3;
}

17
libethash-cuda/CMakeLists.txt

@ -6,10 +6,19 @@ list(APPEND CUDA_NVCC_FLAGS_RELEASE -O3)
list(APPEND CUDA_NVCC_FLAGS_DEBUG -G)
if(COMPUTE AND (COMPUTE GREATER 0))
list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_${COMPUTE},code=sm_${COMPUTE})
else(COMPUTE AND (COMPUTE GREATER 0))
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20;-gencode arch=compute_30,code=sm_30;-gencode arch=compute_35,code=sm_35;-gencode arch=compute_50,code=sm_50;-gencode arch=compute_52,code=sm_52;-gencode arch=compute_61,code=sm_61)
endif(COMPUTE AND (COMPUTE GREATER 0))
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_${COMPUTE},code=sm_${COMPUTE}")
else()
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS}
"-gencode arch=compute_30,code=sm_30"
"-gencode arch=compute_35,code=sm_35"
"-gencode arch=compute_50,code=sm_50"
"-gencode arch=compute_52,code=sm_52"
"-gencode arch=compute_60,code=sm_60"
"-gencode arch=compute_61,code=sm_61"
)
endif()
file(GLOB sources "*.cpp" "*.cu")
file(GLOB headers "*.h" "*.cuh")

5
libethcore/Miner.h

@ -61,10 +61,9 @@ namespace eth
enum class MinerType
{
CPU,
Mixed,
CL,
CUDA,
Mixed
CUDA
};
/// Describes the progress of a mining operation.

4
libstratum/EthStratumClient.cpp

@ -176,9 +176,7 @@ void EthStratumClient::connect_handler(const boost::system::error_code& ec, tcp:
if (!p_farm->isMining())
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu", false);
else if (m_minerType == MinerType::CL)
if (m_minerType == MinerType::CL)
p_farm->start("opencl", false);
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda", false);

4
libstratum/EthStratumClientV2.cpp

@ -141,9 +141,7 @@ void EthStratumClientV2::connect()
if (!p_farm->isMining())
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu", false);
else if (m_minerType == MinerType::CL)
if (m_minerType == MinerType::CL)
p_farm->start("opencl", false);
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda", false);

Loading…
Cancel
Save