From 8be021fcde6f330f1b0c42fda1db881520c61558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Sun, 23 Apr 2017 21:36:24 +0200 Subject: [PATCH] Drop CPU miner --- ethminer/MinerAux.h | 5 -- libethcore/EthashCPUMiner.cpp | 89 --------------------------------- libethcore/EthashCPUMiner.h | 57 --------------------- libethcore/EthashSealEngine.cpp | 2 - 4 files changed, 153 deletions(-) delete mode 100644 libethcore/EthashCPUMiner.cpp delete mode 100644 libethcore/EthashCPUMiner.h diff --git a/ethminer/MinerAux.h b/ethminer/MinerAux.h index f1c9ab464..76de92b79 100644 --- a/ethminer/MinerAux.h +++ b/ethminer/MinerAux.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #if ETH_ETHASHCL #include @@ -625,7 +624,6 @@ private: GenericFarm f; map::SealerDescriptor> sealers; - sealers["cpu"] = GenericFarm::SealerDescriptor{&EthashCPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashCPUMiner(ci); }}; #if ETH_ETHASHCL sealers["opencl"] = GenericFarm::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashGPUMiner(ci); }}; #endif @@ -692,7 +690,6 @@ private: GenericFarm f; map::SealerDescriptor> sealers; - sealers["cpu"] = GenericFarm::SealerDescriptor{ &EthashCPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashCPUMiner(ci); } }; #if ETH_ETHASHCL sealers["opencl"] = GenericFarm::SealerDescriptor{ &EthashGPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashGPUMiner(ci); } }; #endif @@ -772,7 +769,6 @@ private: void doFarm(MinerType _m, string & _remote, unsigned _recheckPeriod) { map::SealerDescriptor> sealers; - sealers["cpu"] = GenericFarm::SealerDescriptor{&EthashCPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashCPUMiner(ci); }}; #if ETH_ETHASHCL sealers["opencl"] = GenericFarm::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashGPUMiner(ci); }}; #endif @@ -926,7 +922,6 @@ private: void doStratum() { map::SealerDescriptor> sealers; - sealers["cpu"] = GenericFarm::SealerDescriptor{ &EthashCPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashCPUMiner(ci); } }; #if ETH_ETHASHCL sealers["opencl"] = GenericFarm::SealerDescriptor{ &EthashGPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashGPUMiner(ci); } }; #endif diff --git a/libethcore/EthashCPUMiner.cpp b/libethcore/EthashCPUMiner.cpp deleted file mode 100644 index ac9301ded..000000000 --- a/libethcore/EthashCPUMiner.cpp +++ /dev/null @@ -1,89 +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 . -*/ -/** @file EthashCPUMiner.cpp - * @author Gav Wood - * @date 2014 - * - * Determines the PoW algorithm. - */ - -#include "EthashCPUMiner.h" -#include -#include -#include -#include -using namespace std; -using namespace dev; -using namespace eth; - -unsigned EthashCPUMiner::s_numInstances = 0; - -EthashCPUMiner::EthashCPUMiner(GenericMiner::ConstructionInfo const& _ci): - GenericMiner(_ci), Worker("miner" + toString(index())) -{ -} - -EthashCPUMiner::~EthashCPUMiner() -{ -} - -void EthashCPUMiner::kickOff() -{ - stopWorking(); - startWorking(); -} - -void EthashCPUMiner::pause() -{ - stopWorking(); -} - -void EthashCPUMiner::workLoop() -{ - auto tid = std::this_thread::get_id(); - static std::mt19937_64 s_eng((time(0) + std::hash()(tid))); - - uint64_t tryNonce = s_eng(); - ethash_return_value ethashReturn; - - WorkPackage w = work(); - - EthashAux::FullType dag; - while (!shouldStop() && !dag) - { - while (!shouldStop() && EthashAux::computeFull(w.seedHash, true) != 100) - this_thread::sleep_for(chrono::milliseconds(500)); - dag = EthashAux::full(w.seedHash, false); - } - - h256 boundary = w.boundary; - unsigned hashCount = 1; - for (; !shouldStop(); tryNonce++, hashCount++) - { - ethashReturn = ethash_full_compute(dag->full, *(ethash_h256_t*)w.headerHash.data(), tryNonce); - h256 value = h256((uint8_t*)ðashReturn.result, h256::ConstructFromPointer); - if (value <= boundary && submitProof(EthashProofOfWork::Solution{(h64)(u64)tryNonce, h256((uint8_t*)ðashReturn.mix_hash, h256::ConstructFromPointer)})) - break; - if (!(hashCount % 100)) - accumulateHashes(100); - } -} - -std::string EthashCPUMiner::platformInfo() -{ - return toString(std::thread::hardware_concurrency()) + "-thread CPU"; -} diff --git a/libethcore/EthashCPUMiner.h b/libethcore/EthashCPUMiner.h deleted file mode 100644 index ce464b0e2..000000000 --- a/libethcore/EthashCPUMiner.h +++ /dev/null @@ -1,57 +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 . -*/ -/** @file EthashCPUMiner.h - * @author Gav Wood - * @date 2014 - * - * Determines the PoW algorithm. - */ - -#pragma once - -#include "libdevcore/Worker.h" -#include "EthashAux.h" -#include "Miner.h" - -namespace dev -{ -namespace eth -{ - -class EthashCPUMiner: public GenericMiner, Worker -{ -public: - EthashCPUMiner(GenericMiner::ConstructionInfo const& _ci); - ~EthashCPUMiner(); - - static unsigned instances() { return s_numInstances > 0 ? s_numInstances : std::thread::hardware_concurrency(); } - static std::string platformInfo(); - static void listDevices() {} - static bool configureGPU(unsigned, unsigned, unsigned, unsigned, unsigned, bool, unsigned, uint64_t) { return false; } - static void setNumInstances(unsigned _instances) { s_numInstances = std::min(_instances, std::thread::hardware_concurrency()); } - -protected: - void kickOff() override; - void pause() override; - -private: - void workLoop() override; - static unsigned s_numInstances; -}; - -} -} diff --git a/libethcore/EthashSealEngine.cpp b/libethcore/EthashSealEngine.cpp index 0983e053f..9ade2bbf2 100644 --- a/libethcore/EthashSealEngine.cpp +++ b/libethcore/EthashSealEngine.cpp @@ -22,7 +22,6 @@ */ #include "EthashSealEngine.h" -#include "EthashCPUMiner.h" #include "EthashGPUMiner.h" #include "EthashCUDAMiner.h" using namespace std; @@ -32,7 +31,6 @@ using namespace eth; EthashSealEngine::EthashSealEngine() { map::SealerDescriptor> sealers; - sealers["cpu"] = GenericFarm::SealerDescriptor{&EthashCPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashCPUMiner(ci); }}; #if ETH_ETHASHCL sealers["opencl"] = GenericFarm::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner::ConstructionInfo ci){ return new EthashGPUMiner(ci); }}; #endif