Browse Source

Merge pull request #34 from ethereum-mining/de-template

De-template Miner class
cl-refactor
Paweł Bylica 7 years ago
committed by GitHub
parent
commit
60aea9246b
  1. 50
      ethminer/MinerAux.h
  2. 1
      libethcore/BlockInfo.cpp
  3. 11
      libethcore/BlockInfo.h
  4. 66
      libethcore/Common.h
  5. 8
      libethcore/EthashAux.cpp
  6. 60
      libethcore/EthashAux.h
  7. 4
      libethcore/EthashCUDAMiner.cpp
  8. 4
      libethcore/EthashCUDAMiner.h
  9. 21
      libethcore/EthashGPUMiner.cpp
  10. 4
      libethcore/EthashGPUMiner.h
  11. 1
      libethcore/Exceptions.h
  12. 12
      libethcore/Farm.h
  13. 12
      libethcore/Miner.cpp
  14. 30
      libethcore/Miner.h
  15. 8
      libstratum/EthStratumClient.cpp
  16. 10
      libstratum/EthStratumClient.h
  17. 8
      libstratum/EthStratumClientV2.cpp
  18. 10
      libstratum/EthStratumClientV2.h

50
ethminer/MinerAux.h

@ -604,16 +604,16 @@ private:
genesis.setDifficulty(1 << 18);
cdebug << genesis.boundary();
GenericFarm<EthashProofOfWork> f;
map<string, GenericFarm<EthashProofOfWork>::SealerDescriptor> sealers;
Farm f;
map<string, Farm::SealerDescriptor> sealers;
#if ETH_ETHASHCL
sealers["opencl"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashGPUMiner(ci); }};
sealers["opencl"] = Farm::SealerDescriptor{&EthashGPUMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashGPUMiner(ci); }};
#endif
#if ETH_ETHASHCUDA
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashCUDAMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
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;
@ -670,13 +670,13 @@ private:
genesis.setDifficulty(1 << 18);
cdebug << genesis.boundary();
GenericFarm<EthashProofOfWork> f;
map<string, GenericFarm<EthashProofOfWork>::SealerDescriptor> sealers;
Farm f;
map<string, Farm::SealerDescriptor> sealers;
#if ETH_ETHASHCL
sealers["opencl"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashGPUMiner(ci); } };
sealers["opencl"] = Farm::SealerDescriptor{ &EthashGPUMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashGPUMiner(ci); } };
#endif
#if ETH_ETHASHCUDA
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashCUDAMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
sealers["cuda"] = Farm::SealerDescriptor{ &EthashCUDAMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
#endif
f.setSealers(sealers);
@ -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;
@ -750,12 +750,12 @@ private:
void doFarm(MinerType _m, string & _remote, unsigned _recheckPeriod)
{
map<string, GenericFarm<EthashProofOfWork>::SealerDescriptor> sealers;
map<string, Farm::SealerDescriptor> sealers;
#if ETH_ETHASHCL
sealers["opencl"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashGPUMiner(ci); }};
sealers["opencl"] = Farm::SealerDescriptor{&EthashGPUMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashGPUMiner(ci); }};
#endif
#if ETH_ETHASHCUDA
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashCUDAMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
sealers["cuda"] = Farm::SealerDescriptor{ &EthashCUDAMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
#endif
(void)_m;
(void)_remote;
@ -768,7 +768,7 @@ private:
FarmClient * prpc = &rpc;
h256 id = h256::random();
GenericFarm<EthashProofOfWork> f;
Farm f;
f.setSealers(sealers);
if (_m == MinerType::CPU)
f.start("cpu", false);
@ -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;
@ -902,17 +902,17 @@ private:
#if ETH_STRATUM
void doStratum()
{
map<string, GenericFarm<EthashProofOfWork>::SealerDescriptor> sealers;
map<string, Farm::SealerDescriptor> sealers;
#if ETH_ETHASHCL
sealers["opencl"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashGPUMiner(ci); } };
sealers["opencl"] = Farm::SealerDescriptor{ &EthashGPUMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashGPUMiner(ci); } };
#endif
#if ETH_ETHASHCUDA
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashCUDAMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
sealers["cuda"] = Farm::SealerDescriptor{ &EthashCUDAMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
#endif
if (!m_farmRecheckSet)
m_farmRecheckPeriod = m_defaultStratumFarmRecheckPeriod;
GenericFarm<EthashProofOfWork> f;
Farm f;
// this is very ugly, but if Stratum Client V2 tunrs out to be a success, V1 will be completely removed anyway
if (m_stratumClientVersion == 1) {
@ -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;

1
libethcore/BlockInfo.cpp

@ -22,7 +22,6 @@
#include <libdevcore/Common.h>
#include <libdevcore/Log.h>
#include <libdevcore/RLP.h>
#include <libethcore/Common.h>
#include "EthashAux.h"
#include "Exceptions.h"
#include "BlockInfo.h"

11
libethcore/BlockInfo.h

@ -24,7 +24,6 @@
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcore/SHA3.h>
#include "Common.h"
#include "Exceptions.h"
namespace dev
@ -32,6 +31,16 @@ namespace dev
namespace eth
{
/// An Ethereum address: 20 bytes.
using Address = h160;
/// The log bloom's size (2048-bit).
using LogBloom = h2048;
using Nonce = h64;
using BlockNumber = unsigned;
enum IncludeProof
{
WithoutProof = 0,

66
libethcore/Common.h

@ -1,66 +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 Common.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*
* Ethereum-specific data structures & algorithms.
*/
#pragma once
#include <string>
#include <functional>
#include <libdevcore/Common.h>
#include <libdevcore/Exceptions.h>
#include <libdevcore/FixedHash.h>
namespace dev
{
namespace eth
{
/// An Ethereum address: 20 bytes.
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
using Address = h160;
DEV_SIMPLE_EXCEPTION(InvalidAddress);
/// The log bloom's size (2048-bit).
using LogBloom = h2048;
/// Many log blooms.
using LogBlooms = std::vector<LogBloom>;
using Nonce = h64;
using BlockNumber = unsigned;
// TODO: move back into a mining subsystem and have it be accessible from Sealant only via a dynamic_cast.
/**
* @brief Describes the progress of a mining operation.
*/
struct WorkingProgress
{
// MiningProgress& operator+=(MiningProgress const& _mp) { hashes += _mp.hashes; ms = std::max(ms, _mp.ms); return *this; }
uint64_t hashes = 0; ///< Total number of hashes computed.
uint64_t ms = 0; ///< Total number of milliseconds of mining thus far.
uint64_t rate() const { return ms == 0 ? 0 : hashes * 1000 / ms; }
};
}
}

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;

4
libethcore/EthashCUDAMiner.cpp

@ -108,7 +108,7 @@ unsigned EthashCUDAMiner::s_numInstances = 0;
int EthashCUDAMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
EthashCUDAMiner::EthashCUDAMiner(ConstructionInfo const& _ci) :
GenericMiner<EthashProofOfWork>(_ci),
Miner(_ci),
Worker("cudaminer" + toString(index())),
m_hook( new EthashCUDAHook(this))
{
@ -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;

4
libethcore/EthashCUDAMiner.h

@ -36,7 +36,7 @@ namespace eth
{
class EthashCUDAHook;
class EthashCUDAMiner : public GenericMiner<EthashProofOfWork>, Worker
class EthashCUDAMiner : public Miner, Worker
{
friend class dev::eth::EthashCUDAHook;
@ -80,7 +80,7 @@ class EthashCUDAHook;
void workLoop() override;
bool report(uint64_t _nonce);
using GenericMiner<EthashProofOfWork>::accumulateHashes;
using Miner::accumulateHashes;
EthashCUDAHook* m_hook = nullptr;
ethash_cuda_miner* m_miner = nullptr;

21
libethcore/EthashGPUMiner.cpp

@ -107,7 +107,7 @@ unsigned EthashGPUMiner::s_numInstances = 0;
int EthashGPUMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
EthashGPUMiner::EthashGPUMiner(ConstructionInfo const& _ci):
GenericMiner<EthashProofOfWork>(_ci),
Miner(_ci),
Worker("openclminer" + toString(index())),
m_hook(new EthashCLHook(this))
{
@ -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();

4
libethcore/EthashGPUMiner.h

@ -36,7 +36,7 @@ namespace eth
{
class EthashCLHook;
class EthashGPUMiner: public GenericMiner<EthashProofOfWork>, Worker
class EthashGPUMiner: public Miner, Worker
{
friend class dev::eth::EthashCLHook;
@ -76,7 +76,7 @@ private:
void workLoop() override;
bool report(uint64_t _nonce);
using GenericMiner<EthashProofOfWork>::accumulateHashes;
using Miner::accumulateHashes;
EthashCLHook* m_hook = nullptr;
ethash_cl_miner* m_miner = nullptr;

1
libethcore/Exceptions.h

@ -22,7 +22,6 @@
#pragma once
#include <libdevcore/Exceptions.h>
#include "Common.h"
namespace dev
{

12
libethcore/Farm.h

@ -26,7 +26,6 @@
#include <atomic>
#include <libdevcore/Common.h>
#include <libdevcore/Worker.h>
#include <libethcore/Common.h>
#include <libethcore/Miner.h>
#include <libethcore/BlockInfo.h>
@ -41,21 +40,16 @@ namespace eth
* Miners ask for work, then submit proofs
* @threadsafe
*/
template <class PoW>
class GenericFarm: public GenericFarmFace<PoW>
class Farm: public FarmFace
{
public:
using WorkPackage = typename PoW::WorkPackage;
using Solution = typename PoW::Solution;
using Miner = GenericMiner<PoW>;
struct SealerDescriptor
{
std::function<unsigned()> instances;
std::function<Miner*(typename Miner::ConstructionInfo ci)> create;
std::function<Miner*(Miner::ConstructionInfo ci)> create;
};
~GenericFarm()
~Farm()
{
stop();
}

12
libethcore/Miner.cpp

@ -4,16 +4,12 @@
using namespace dev;
using namespace eth;
template <>
unsigned dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::s_dagLoadMode = 0;
unsigned dev::eth::Miner::s_dagLoadMode = 0;
template <>
volatile unsigned dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::s_dagLoadIndex = 0;
volatile unsigned dev::eth::Miner::s_dagLoadIndex = 0;
template <>
unsigned dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::s_dagCreateDevice = 0;
unsigned dev::eth::Miner::s_dagCreateDevice = 0;
template <>
volatile void* dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::s_dagInHostMemory = NULL;
volatile void* dev::eth::Miner::s_dagInHostMemory = NULL;

30
libethcore/Miner.h

@ -29,7 +29,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/Log.h>
#include <libdevcore/Worker.h>
#include <libethcore/Common.h>
#include "EthashAux.h"
#define MINER_WAIT_STATE_UNKNOWN 0
#define MINER_WAIT_STATE_WORK 1
@ -67,7 +67,13 @@ enum class MinerType
Mixed
};
struct MineInfo: public WorkingProgress {};
/// Describes the progress of a mining operation.
struct WorkingProgress
{
uint64_t hashes = 0; ///< Total number of hashes computed.
uint64_t ms = 0; ///< Total number of milliseconds of mining thus far.
uint64_t rate() const { return ms == 0 ? 0 : hashes * 1000 / ms; }
};
inline std::ostream& operator<<(std::ostream& _out, WorkingProgress _p)
{
@ -109,7 +115,7 @@ inline std::ostream& operator<<(std::ostream& os, SolutionStats s)
return os << "[A" << s.getAccepts() << "+" << s.getAcceptedStales() << ":R" << s.getRejects() << "+" << s.getRejectedStales() << ":F" << s.getFailures() << "]";
}
template <class PoW> class GenericMiner;
class Miner;
/**
@ -117,19 +123,14 @@ template <class PoW> class GenericMiner;
* @warning Must be implemented in a threadsafe manner since it will be called from multiple
* miner threads.
*/
template <class PoW> class GenericFarmFace
class FarmFace
{
public:
using WorkPackage = typename PoW::WorkPackage;
using Solution = typename PoW::Solution;
using Miner = GenericMiner<PoW>;
virtual ~GenericFarmFace() {}
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 .
*/
@ -140,19 +141,16 @@ public:
* @brief A miner - a member and adoptee of the Farm.
* @warning Not threadsafe. It is assumed Farm will synchronise calls to/from this class.
*/
template <class PoW> class GenericMiner
class Miner
{
public:
using WorkPackage = typename PoW::WorkPackage;
using Solution = typename PoW::Solution;
using FarmFace = GenericFarmFace<PoW>;
using ConstructionInfo = std::pair<FarmFace*, unsigned>;
GenericMiner(ConstructionInfo const& _ci):
Miner(ConstructionInfo const& _ci):
m_farm(_ci.first),
m_index(_ci.second)
{}
virtual ~GenericMiner() {}
virtual ~Miner() {}
// API FOR THE FARM TO CALL IN WITH

8
libstratum/EthStratumClient.cpp

@ -27,7 +27,7 @@ static void diffToTarget(uint32_t *target, double diff)
}
EthStratumClient::EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email)
EthStratumClient::EthStratumClient(Farm* f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email)
: m_socket(m_io_service)
{
m_minerType = m;
@ -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();

10
libstratum/EthStratumClient.h

@ -21,7 +21,7 @@ using namespace dev::eth;
class EthStratumClient
{
public:
EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email);
EthStratumClient(Farm* f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email);
~EthStratumClient();
void setFailover(string const & host, string const & port);
@ -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();
@ -68,10 +68,10 @@ private:
std::mutex x_pending;
int m_pending;
GenericFarm<EthashProofOfWork> * p_farm;
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;

8
libstratum/EthStratumClientV2.cpp

@ -27,7 +27,7 @@ static void diffToTarget(uint32_t *target, double diff)
}
EthStratumClientV2::EthStratumClientV2(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email)
EthStratumClientV2::EthStratumClientV2(Farm* f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email)
: Worker("stratum"),
m_socket(m_io_service)
{
@ -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();

10
libstratum/EthStratumClientV2.h

@ -22,7 +22,7 @@ using namespace dev::eth;
class EthStratumClientV2 : public Worker
{
public:
EthStratumClientV2(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email);
EthStratumClientV2(Farm* f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, int const & protocol, string const & email);
~EthStratumClientV2();
void setFailover(string const & host, string const & port);
@ -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;
@ -64,10 +64,10 @@ private:
string m_response;
GenericFarm<EthashProofOfWork> * p_farm;
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