Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit f3270b0

Browse files
committedJul 28, 2017
Do to set empty work
The farm sometimes sends empty work package to miners. The setWork() has magic side effects of restarting miners. We want to get rid of this -- miners should not be restarted this way.
1 parent 5cc3090 commit f3270b0

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed
 

‎ethminer/MinerAux.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,11 @@ class MinerCLI
614614
//genesis.prep();
615615

616616
genesis.setDifficulty(u256(1) << 63);
617-
f.setWork(genesis);
618617
if (_m == MinerType::CL)
619618
f.start("opencl", false);
620619
else if (_m == MinerType::CUDA)
621620
f.start("cuda", false);
621+
f.setWork(genesis);
622622

623623
map<uint64_t, WorkingProgress> results;
624624
uint64_t mean = 0;
@@ -677,12 +677,12 @@ class MinerCLI
677677
//genesis.prep();
678678

679679
genesis.setDifficulty(u256(1) << difficulty);
680-
f.setWork(genesis);
681680

682681
if (_m == MinerType::CL)
683682
f.start("opencl", false);
684683
else if (_m == MinerType::CUDA)
685684
f.start("cuda", false);
685+
f.setWork(genesis);
686686

687687
int time = 0;
688688

‎libdevcore/Worker.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum class WorkerState
4141

4242
class Worker
4343
{
44-
protected:
44+
public:
4545
Worker(std::string const& _name): m_name(_name) {}
4646

4747
Worker(Worker const&) = delete;
@@ -55,11 +55,11 @@ class Worker
5555
/// Stop worker thread; causes call to stopWorking().
5656
void stopWorking();
5757

58-
virtual void workLoop() = 0;
59-
6058
bool shouldStop() const { return m_state != WorkerState::Started; }
6159

6260
private:
61+
virtual void workLoop() = 0;
62+
6363
std::string m_name;
6464

6565
mutable Mutex x_work; ///< Lock for the network existance.

‎libethash-cl/CLMiner.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ void CLMiner::workLoop()
143143
// take local copy of work since it may end up being overwritten by kickOff/pause.
144144
try {
145145
const WorkPackage w = work();
146-
cllog << "Set work. Header" << w.header << "target" << w.boundary.hex().substr(0, 12);
146+
147+
if (!w)
148+
{
149+
cllog << "No work. Pause.";
150+
return;
151+
}
152+
153+
cllog << "Set work. Header" << w.header << "target" << w.boundary.hex();
147154
if (m_seed != w.seed)
148155
{
149156
if (s_dagLoadMode == DAG_LOAD_MODE_SEQUENTIAL)

‎libethcore/Farm.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ class Farm: public FarmFace
100100
}
101101
for (unsigned i = start; i < ins; ++i)
102102
{
103+
// TODO: Improve miners creation, use unique_ptr.
103104
m_miners.push_back(std::shared_ptr<Miner>(m_sealers[_sealer].create(*this, i)));
104-
m_miners.back()->setWork(m_work);
105+
106+
// Start miners' threads. They should pause waiting for new work
107+
// package.
108+
m_miners.back()->startWorking();
105109
}
106110
m_isMining = true;
107111
m_lastSealer = _sealer;

‎libethcore/Miner.h

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class Miner: public Worker
155155
Guard l(x_work);
156156
m_work = _work;
157157
}
158+
assert(!!_work);
158159
if (!!_work)
159160
{
160161
pause();

0 commit comments

Comments
 (0)
This repository has been archived.