Browse Source

Remove EthashProofOfWork namespace

cl-refactor
Paweł Bylica 8 years ago
parent
commit
d5618a48eb
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 18
      ethminer/MinerAux.h
  2. 8
      libethcore/EthashAux.cpp
  3. 60
      libethcore/EthashAux.h
  4. 2
      libethcore/EthashCUDAMiner.cpp
  5. 19
      libethcore/EthashGPUMiner.cpp
  6. 3
      libethcore/Farm.h
  7. 6
      libethcore/Miner.h
  8. 6
      libstratum/EthStratumClient.cpp
  9. 6
      libstratum/EthStratumClient.h
  10. 6
      libstratum/EthStratumClientV2.cpp
  11. 6
      libstratum/EthStratumClientV2.h

18
ethminer/MinerAux.h

@ -613,7 +613,7 @@ private:
sealers["cuda"] = Farm::SealerDescriptor{ &EthashCUDAMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
#endif
f.setSealers(sealers);
f.onSolutionFound([&](EthashProofOfWork::Solution) { return false; });
f.onSolutionFound([&](Solution) { return false; });
string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "CL" : "CUDA");
cout << "Benchmarking on platform: " << platformInfo << endl;
@ -698,11 +698,11 @@ private:
int time = 0;
EthashProofOfWork::WorkPackage current = EthashProofOfWork::WorkPackage(genesis);
WorkPackage current = WorkPackage(genesis);
while (true) {
bool completed = false;
EthashProofOfWork::Solution solution;
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
Solution solution;
f.onSolutionFound([&](Solution sol)
{
solution = sol;
return completed = true;
@ -776,14 +776,14 @@ private:
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda", false);
EthashProofOfWork::WorkPackage current, previous;
WorkPackage current, previous;
std::mutex x_current;
while (m_running)
try
{
bool completed = false;
EthashProofOfWork::Solution solution;
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
Solution solution;
f.onSolutionFound([&](Solution sol)
{
solution = sol;
return completed = true;
@ -930,7 +930,7 @@ private:
}
f.setSealers(sealers);
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
f.onSolutionFound([&](Solution sol)
{
if (client.isConnected()) {
client.submit(sol);
@ -974,7 +974,7 @@ private:
}
f.setSealers(sealers);
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
f.onSolutionFound([&](Solution sol)
{
client.submit(sol);
return false;

8
libethcore/EthashAux.cpp

@ -107,15 +107,15 @@ bytesConstRef EthashAux::LightAllocation::data() const
return bytesConstRef((byte const*)light->cache, size);
}
EthashProofOfWork::Result EthashAux::LightAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const
Result EthashAux::LightAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const
{
ethash_return_value r = ethash_light_compute(light, *(ethash_h256_t*)_headerHash.data(), (uint64_t)(u64)_nonce);
if (!r.success)
BOOST_THROW_EXCEPTION(DAGCreationFailure());
return EthashProofOfWork::Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)};
return Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)};
}
EthashProofOfWork::Result EthashAux::eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept
Result EthashAux::eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept
{
try
{
@ -123,6 +123,6 @@ EthashProofOfWork::Result EthashAux::eval(h256 const& _seedHash, h256 const& _he
}
catch(...)
{
return EthashProofOfWork::Result{~h256(), h256()};
return Result{~h256(), h256()};
}
}

60
libethcore/EthashAux.h

@ -32,39 +32,35 @@ namespace dev
namespace eth
{
/// Proof of work definition for Ethash.
struct EthashProofOfWork
struct Solution
{
struct Solution
{
Nonce nonce;
h256 mixHash;
};
Nonce nonce;
h256 mixHash;
};
struct Result
{
h256 value;
h256 mixHash;
};
struct Result
{
h256 value;
h256 mixHash;
};
struct WorkPackage
{
WorkPackage() = default;
WorkPackage(BlockHeader const& _bh) :
boundary(_bh.boundary()),
headerHash(_bh.hashWithout()),
seedHash(_bh.seedHash())
{ }
void reset() { headerHash = h256(); }
operator bool() const { return headerHash != h256(); }
h256 boundary;
h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
h256 seedHash;
uint64_t startNonce = 0;
int exSizeBits = -1;
};
struct WorkPackage
{
WorkPackage() = default;
WorkPackage(BlockHeader const& _bh) :
boundary(_bh.boundary()),
headerHash(_bh.hashWithout()),
seedHash(_bh.seedHash())
{ }
void reset() { headerHash = h256(); }
operator bool() const { return headerHash != h256(); }
h256 boundary;
h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
h256 seedHash;
uint64_t startNonce = 0;
int exSizeBits = -1;
};
class EthashAux
@ -77,7 +73,7 @@ public:
LightAllocation(h256 const& _seedHash);
~LightAllocation();
bytesConstRef data() const;
EthashProofOfWork::Result compute(h256 const& _headerHash, Nonce const& _nonce) const;
Result compute(h256 const& _headerHash, Nonce const& _nonce) const;
ethash_light_t light;
uint64_t size;
};
@ -89,7 +85,7 @@ public:
static LightType light(h256 const& _seedHash);
static EthashProofOfWork::Result eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept;
static Result eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept;
private:
EthashAux() = default;

2
libethcore/EthashCUDAMiner.cpp

@ -124,7 +124,7 @@ EthashCUDAMiner::~EthashCUDAMiner()
bool EthashCUDAMiner::report(uint64_t _nonce)
{
Nonce n = (Nonce)(u64)_nonce;
EthashProofOfWork::Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
if (r.value < work().boundary)
return submitProof(Solution{ n, r.mixHash });
return false;

19
libethcore/EthashGPUMiner.cpp

@ -123,7 +123,7 @@ EthashGPUMiner::~EthashGPUMiner()
bool EthashGPUMiner::report(uint64_t _nonce)
{
Nonce n = (Nonce)(u64)_nonce;
EthashProofOfWork::Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
if (r.value < work().boundary)
return submitProof(Solution{n, r.mixHash});
return false;
@ -158,23 +158,6 @@ void EthashGPUMiner::workLoop()
unsigned device = s_devices[index()] > -1 ? s_devices[index()] : index();
/*
EthashAux::FullType dag;
while (true)
{
if ((dag = EthashAux::full(w.seedHash, true)))
break;
if (shouldStop())
{
delete m_miner;
m_miner = nullptr;
return;
}
cnote << "Awaiting DAG";
this_thread::sleep_for(chrono::milliseconds(500));
}
*/
EthashAux::LightType light;
light = EthashAux::light(w.seedHash);
bytesConstRef lightData = light->data();

3
libethcore/Farm.h

@ -44,9 +44,6 @@ namespace eth
class Farm: public FarmFace
{
public:
using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution;
struct SealerDescriptor
{
std::function<unsigned()> instances;

6
libethcore/Miner.h

@ -119,15 +119,11 @@ class Miner;
class FarmFace
{
public:
using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution;
virtual ~FarmFace() = default;
/**
* @brief Called from a Miner to note a WorkPackage has a solution.
* @param _p The solution.
* @param _wp The WorkPackage that the Solution is for; this will be reset if the work is accepted.
* @param _finder The miner that found it.
* @return true iff the solution was good (implying that mining should be .
*/
@ -141,8 +137,6 @@ public:
class Miner
{
public:
using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution;
using ConstructionInfo = std::pair<FarmFace*, unsigned>;
Miner(ConstructionInfo const& _ci):

6
libstratum/EthStratumClient.cpp

@ -504,11 +504,11 @@ void EthStratumClient::work_timeout_handler(const boost::system::error_code& ec)
}
}
bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {
bool EthStratumClient::submit(Solution solution) {
x_current.lock();
EthashProofOfWork::WorkPackage tempWork(m_current);
WorkPackage tempWork(m_current);
string temp_job = m_job;
EthashProofOfWork::WorkPackage tempPreviousWork(m_previous);
WorkPackage tempPreviousWork(m_previous);
string temp_previous_job = m_previousJob;
x_current.unlock();

6
libstratum/EthStratumClient.h

@ -32,7 +32,7 @@ public:
h256 currentHeaderHash() { return m_current.headerHash; }
bool current() { return m_current; }
unsigned waitState() { return m_waitState; }
bool submit(EthashProofOfWork::Solution solution);
bool submit(Solution solution);
void reconnect();
private:
void connect();
@ -70,8 +70,8 @@ private:
Farm* p_farm;
std::mutex x_current;
EthashProofOfWork::WorkPackage m_current;
EthashProofOfWork::WorkPackage m_previous;
WorkPackage m_current;
WorkPackage m_previous;
bool m_stale = false;

6
libstratum/EthStratumClientV2.cpp

@ -446,11 +446,11 @@ void EthStratumClientV2::work_timeout_handler(const boost::system::error_code& e
}
}
bool EthStratumClientV2::submit(EthashProofOfWork::Solution solution) {
bool EthStratumClientV2::submit(Solution solution) {
x_current.lock();
EthashProofOfWork::WorkPackage tempWork(m_current);
WorkPackage tempWork(m_current);
string temp_job = m_job;
EthashProofOfWork::WorkPackage tempPreviousWork(m_previous);
WorkPackage tempPreviousWork(m_previous);
string temp_previous_job = m_previousJob;
x_current.unlock();

6
libstratum/EthStratumClientV2.h

@ -33,7 +33,7 @@ public:
h256 currentHeaderHash() { return m_current.headerHash; }
bool current() { return m_current; }
unsigned waitState() { return m_waitState; }
bool submit(EthashProofOfWork::Solution solution);
bool submit(Solution solution);
void reconnect();
private:
void workLoop() override;
@ -66,8 +66,8 @@ private:
Farm* p_farm;
mutex x_current;
EthashProofOfWork::WorkPackage m_current;
EthashProofOfWork::WorkPackage m_previous;
WorkPackage m_current;
WorkPackage m_previous;
bool m_stale = false;

Loading…
Cancel
Save