const& _h)
- {
- return (*this |= _h.template bloomPart());
- }
-
- template inline bool containsBloom(FixedHash const& _h)
- {
- return contains(_h.template bloomPart());
- }
-
- template inline FixedHash bloomPart() const
- {
- unsigned const c_bloomBits = M * 8;
- unsigned const c_mask = c_bloomBits - 1;
- unsigned const c_bloomBytes = (StaticLog2::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 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 m_data; ///< The binary data.
};
-template
-class SecureFixedHash: private FixedHash
-{
-public:
- using ConstructFromHashType = typename FixedHash::ConstructFromHashType;
- using ConstructFromStringType = typename FixedHash::ConstructFromStringType;
- using ConstructFromPointerType = typename FixedHash::ConstructFromPointerType;
- SecureFixedHash() = default;
- explicit SecureFixedHash(bytes const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {}
- explicit SecureFixedHash(bytesConstRef _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {}
- explicit SecureFixedHash(bytesSec const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b.ref(), _t) {}
- template explicit SecureFixedHash(FixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h, _t) {}
- template explicit SecureFixedHash(SecureFixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h.makeInsecure(), _t) {}
- explicit SecureFixedHash(std::string const& _s, ConstructFromStringType _t = FixedHash::FromHex, ConstructFromHashType _ht = FixedHash::FailIfDifferent): FixedHash(_s, _t, _ht) {}
- explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash(_d, _t) {}
- ~SecureFixedHash() { ref().cleanse(); }
-
- SecureFixedHash& operator=(SecureFixedHash const& _c)
- {
- if (&_c == this)
- return *this;
- ref().cleanse();
- FixedHash::operator=(static_cast const&>(_c));
- return *this;
- }
-
- using FixedHash::size;
-
- bytesSec asBytesSec() const { return bytesSec(ref()); }
-
- FixedHash const& makeInsecure() const { return static_cast const&>(*this); }
- FixedHash& writable() { clear(); return static_cast&>(*this); }
-
- using FixedHash::operator bool;
-
- // The obvious comparison operators.
- bool operator==(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator==(static_cast const&>(_c)); }
- bool operator!=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator!=(static_cast const&>(_c)); }
- bool operator<(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<(static_cast const&>(_c)); }
- bool operator>=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>=(static_cast const&>(_c)); }
- bool operator<=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<=(static_cast const&>(_c)); }
- bool operator>(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>(static_cast const&>(_c)); }
-
- using FixedHash::operator==;
- using FixedHash::operator!=;
- using FixedHash::operator<;
- using FixedHash::operator>=;
- using FixedHash::operator<=;
- using FixedHash::operator>;
-
- // The obvious binary operators.
- SecureFixedHash& operator^=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; }
- SecureFixedHash operator^(FixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; }
- SecureFixedHash& operator|=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; }
- SecureFixedHash operator|(FixedHash const& _c) const { return SecureFixedHash(*this) |= _c; }
- SecureFixedHash& operator&=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; }
- SecureFixedHash operator&(FixedHash const& _c) const { return SecureFixedHash(*this) &= _c; }
-
- SecureFixedHash& operator^=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; }
- SecureFixedHash operator^(SecureFixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; }
- SecureFixedHash& operator|=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; }
- SecureFixedHash operator|(SecureFixedHash const& _c) const { return SecureFixedHash(*this) |= _c; }
- SecureFixedHash& operator&=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; }
- SecureFixedHash operator&(SecureFixedHash const& _c) const { return SecureFixedHash(*this) &= _c; }
- SecureFixedHash operator~() const { auto r = ~static_cast const&>(*this); return static_cast(r); }
-
- using FixedHash::abridged;
- using FixedHash::abridgedMiddle;
-
- bytesConstRef ref() const { return FixedHash::ref(); }
- byte const* data() const { return FixedHash::data(); }
-
- using FixedHash::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 const& _h)
return _out;
}
-/// Stream I/O for the SecureFixedHash class.
-template
-inline std::ostream& operator<<(std::ostream& _out, SecureFixedHash const& _h)
-{
- _out << "SecureFixedHash#" << std::hex << typename FixedHash::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;
using h256Hash = std::unordered_set;
using h160Hash = std::unordered_set;
-/// 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;
diff --git a/libdevcore/Guards.h b/libdevcore/Guards.h
index a65695863..064be8ab5 100644
--- a/libdevcore/Guards.h
+++ b/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;
-
template
class Notified
{
diff --git a/libdevcore/Log.cpp b/libdevcore/Log.cpp
index cad77cb3f..f64f682c3 100644
--- a/libdevcore/Log.cpp
+++ b/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 dev::g_logPost = simpleDebugOut;
diff --git a/libdevcore/Log.h b/libdevcore/Log.h
index d6e2ef44d..8d8c2b3bc 100644
--- a/libdevcore/Log.h
+++ b/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 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; }
diff --git a/libdevcore/RLP.cpp b/libdevcore/RLP.cpp
index 94e4ee579..1a934c03f 100644
--- a/libdevcore/RLP.cpp
+++ b/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;
-}
diff --git a/libdevcore/RLP.h b/libdevcore/RLP.h
index 701f4b8e8..23a1a347b 100644
--- a/libdevcore/RLP.h
+++ b/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
std::vector toVector() const
@@ -219,16 +211,6 @@ public:
return ret;
}
- template
- std::unordered_set toUnorderedSet() const
- {
- std::unordered_set ret;
- if (isList())
- for (auto const& i: *this)
- ret.insert((T)i);
- return ret;
- }
-
template
std::pair toPair() const
{
@@ -369,20 +351,14 @@ public:
/// Appends a sequence of data to the stream as a list.
template RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); }
template RLPStream& appendVector(std::vector<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
- template RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
- template RLPStream& append(std::set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
- template RLPStream& append(std::unordered_set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
- template RLPStream& append(std::pair 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 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> m_listStack;
};
-template void rlpListAux(RLPStream& _out, _T _t) { _out << _t; }
-template void rlpListAux(RLPStream& _out, _T _t, _Ts ... _ts) { rlpListAux(_out << _t, _ts...); }
-
-/// Export a single item in RLP format, returning a byte array.
-template 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 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);
-
}
diff --git a/libdevcore/SHA3.cpp b/libdevcore/SHA3.cpp
index 3f4fd2c96..89e072ede 100644
--- a/libdevcore/SHA3.cpp
+++ b/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
{
diff --git a/libdevcore/SHA3.h b/libdevcore/SHA3.h
index 00c61b721..db2bda45e 100644
--- a/libdevcore/SHA3.h
+++ b/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 inline h256 sha3(FixedHash const& _input) { return sha3(_input.ref()); }
-extern h256 EmptyListSHA3;
-
}
diff --git a/libethash-cuda/CMakeLists.txt b/libethash-cuda/CMakeLists.txt
index 47233d696..be0239d99 100644
--- a/libethash-cuda/CMakeLists.txt
+++ b/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")
diff --git a/libethcore/Miner.h b/libethcore/Miner.h
index 689649cab..203fbdea6 100644
--- a/libethcore/Miner.h
+++ b/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.
diff --git a/libstratum/EthStratumClient.cpp b/libstratum/EthStratumClient.cpp
index 89c114eef..36ce28b8d 100644
--- a/libstratum/EthStratumClient.cpp
+++ b/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);
diff --git a/libstratum/EthStratumClientV2.cpp b/libstratum/EthStratumClientV2.cpp
index 5284b9395..7bc9823ed 100644
--- a/libstratum/EthStratumClientV2.cpp
+++ b/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);