Browse Source

Remove Generic name prefix

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

32
ethminer/MinerAux.h

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

2
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 }; 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) : EthashCUDAMiner::EthashCUDAMiner(ConstructionInfo const& _ci) :
GenericMiner(_ci), Miner(_ci),
Worker("cudaminer" + toString(index())), Worker("cudaminer" + toString(index())),
m_hook( new EthashCUDAHook(this)) m_hook( new EthashCUDAHook(this))
{ {

4
libethcore/EthashCUDAMiner.h

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

2
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 }; 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): EthashGPUMiner::EthashGPUMiner(ConstructionInfo const& _ci):
GenericMiner(_ci), Miner(_ci),
Worker("openclminer" + toString(index())), Worker("openclminer" + toString(index())),
m_hook(new EthashCLHook(this)) m_hook(new EthashCLHook(this))
{ {

4
libethcore/EthashGPUMiner.h

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

7
libethcore/Farm.h

@ -41,20 +41,19 @@ namespace eth
* Miners ask for work, then submit proofs * Miners ask for work, then submit proofs
* @threadsafe * @threadsafe
*/ */
class GenericFarm: public GenericFarmFace class Farm: public FarmFace
{ {
public: public:
using WorkPackage = EthashProofOfWork::WorkPackage; using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution; using Solution = EthashProofOfWork::Solution;
using Miner = GenericMiner;
struct SealerDescriptor struct SealerDescriptor
{ {
std::function<unsigned()> instances; std::function<unsigned()> instances;
std::function<Miner*(typename Miner::ConstructionInfo ci)> create; std::function<Miner*(Miner::ConstructionInfo ci)> create;
}; };
~GenericFarm() ~Farm()
{ {
stop(); stop();
} }

8
libethcore/Miner.cpp

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

14
libethcore/Miner.h

@ -108,7 +108,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() << "]"; return os << "[A" << s.getAccepts() << "+" << s.getAcceptedStales() << ":R" << s.getRejects() << "+" << s.getRejectedStales() << ":F" << s.getFailures() << "]";
} }
class GenericMiner; class Miner;
/** /**
@ -116,14 +116,13 @@ class GenericMiner;
* @warning Must be implemented in a threadsafe manner since it will be called from multiple * @warning Must be implemented in a threadsafe manner since it will be called from multiple
* miner threads. * miner threads.
*/ */
class GenericFarmFace class FarmFace
{ {
public: public:
using WorkPackage = EthashProofOfWork::WorkPackage; using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution; using Solution = EthashProofOfWork::Solution;
using Miner = GenericMiner;
virtual ~GenericFarmFace() = default; virtual ~FarmFace() = default;
/** /**
* @brief Called from a Miner to note a WorkPackage has a solution. * @brief Called from a Miner to note a WorkPackage has a solution.
@ -139,19 +138,18 @@ public:
* @brief A miner - a member and adoptee of the Farm. * @brief A miner - a member and adoptee of the Farm.
* @warning Not threadsafe. It is assumed Farm will synchronise calls to/from this class. * @warning Not threadsafe. It is assumed Farm will synchronise calls to/from this class.
*/ */
class GenericMiner class Miner
{ {
public: public:
using WorkPackage = EthashProofOfWork::WorkPackage; using WorkPackage = EthashProofOfWork::WorkPackage;
using Solution = EthashProofOfWork::Solution; using Solution = EthashProofOfWork::Solution;
using FarmFace = GenericFarmFace;
using ConstructionInfo = std::pair<FarmFace*, unsigned>; using ConstructionInfo = std::pair<FarmFace*, unsigned>;
GenericMiner(ConstructionInfo const& _ci): Miner(ConstructionInfo const& _ci):
m_farm(_ci.first), m_farm(_ci.first),
m_index(_ci.second) m_index(_ci.second)
{} {}
virtual ~GenericMiner() {} virtual ~Miner() {}
// API FOR THE FARM TO CALL IN WITH // API FOR THE FARM TO CALL IN WITH

2
libstratum/EthStratumClient.cpp

@ -27,7 +27,7 @@ static void diffToTarget(uint32_t *target, double diff)
} }
EthStratumClient::EthStratumClient(GenericFarm* 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_socket(m_io_service)
{ {
m_minerType = m; m_minerType = m;

4
libstratum/EthStratumClient.h

@ -21,7 +21,7 @@ using namespace dev::eth;
class EthStratumClient class EthStratumClient
{ {
public: public:
EthStratumClient(GenericFarm* 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(); ~EthStratumClient();
void setFailover(string const & host, string const & port); void setFailover(string const & host, string const & port);
@ -68,7 +68,7 @@ private:
std::mutex x_pending; std::mutex x_pending;
int m_pending; int m_pending;
GenericFarm* p_farm; Farm* p_farm;
std::mutex x_current; std::mutex x_current;
EthashProofOfWork::WorkPackage m_current; EthashProofOfWork::WorkPackage m_current;
EthashProofOfWork::WorkPackage m_previous; EthashProofOfWork::WorkPackage m_previous;

2
libstratum/EthStratumClientV2.cpp

@ -27,7 +27,7 @@ static void diffToTarget(uint32_t *target, double diff)
} }
EthStratumClientV2::EthStratumClientV2(GenericFarm* 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"), : Worker("stratum"),
m_socket(m_io_service) m_socket(m_io_service)
{ {

4
libstratum/EthStratumClientV2.h

@ -22,7 +22,7 @@ using namespace dev::eth;
class EthStratumClientV2 : public Worker class EthStratumClientV2 : public Worker
{ {
public: public:
EthStratumClientV2(GenericFarm* 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(); ~EthStratumClientV2();
void setFailover(string const & host, string const & port); void setFailover(string const & host, string const & port);
@ -64,7 +64,7 @@ private:
string m_response; string m_response;
GenericFarm* p_farm; Farm* p_farm;
mutex x_current; mutex x_current;
EthashProofOfWork::WorkPackage m_current; EthashProofOfWork::WorkPackage m_current;
EthashProofOfWork::WorkPackage m_previous; EthashProofOfWork::WorkPackage m_previous;

Loading…
Cancel
Save