Skip to content

Commit 4e5a958

Browse files
mutex changes
1 parent cf9bdd0 commit 4e5a958

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cmake global
22
cmake_minimum_required(VERSION 2.8.12)
33

4-
set(PROJECT_VERSION "2.1.9")
4+
set(PROJECT_VERSION "2.1.10")
55
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
66
cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH
77
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()

libethcore/EthashGPUMiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bool EthashGPUMiner::report(h256 _nonce)
140140
h160 sender(m_farm->hashingAcct);
141141
bytes hash(32);
142142
keccak256_0xBitcoin(challenge, sender, _nonce, hash);
143-
LogF << "Trace: EthashGPUMiner::report, challenge = " << toHex(challenge) << ", sender = " << sender.hex()
143+
LogF << "Trace: EthashGPUMiner::report, challenge = " << toHex(challenge) << ", sender = " << sender.hex()
144144
<< ", hash = " << toHex(hash) << ", target = " << target.hex() << ", miner[" << m_index << "]";
145145
if (h256(hash) < target)
146146
return submitProof(_nonce);

libethcore/Farm.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ class GenericFarm
204204
<< ", target=" << std::hex << std::setw(16) << std::setfill('0') << upper64OfHash(_target);
205205

206206
WriteGuard l(x_minerWork);
207-
if (_challenge == challenge && _target == target)
207+
if (_challenge == m_challenge && _target == m_target)
208208
return;
209-
challenge = _challenge;
210-
target = _target;
209+
m_challenge = _challenge;
210+
m_target = _target;
211211
for (auto const& m: m_miners)
212-
m->setWork(challenge, target);
212+
m->setWork(m_challenge, m_target);
213213
}
214214

215215

@@ -227,7 +227,7 @@ class GenericFarm
227227
m_hashRates->init();
228228
// can't call setWork until we've initialized the hash rates
229229
//for (auto const& m : m_miners)
230-
// m->setWork_token(challenge, target);
230+
// m->setWork_token(m_challenge, m_target);
231231

232232
LogF << "Trace: GenericFarm.start [exit]";
233233
}
@@ -605,16 +605,19 @@ class GenericFarm
605605
*----------------------------------------------------------------------------------*/
606606
bool submitProof(h256 _nonce, Miner* _m)
607607
{
608-
// return true if miner should stop and wait for new work, false otherwise
608+
// return true if miner should stop and wait for new work, false to keep mining
609609
bool shouldStop = false;
610610

611611
LogF << "Trace: GenericFarm.submitProof - nonce = " << _nonce.hex().substr(0, 8) << ", miner = " << _m->index();
612612

613-
if (!x_minerWork.try_lock())
614-
{
615-
LogF << "Trace: GenericFarm.submitProof - mutex locked ... exiting";
616-
return shouldStop;
617-
}
613+
/*
614+
we could block here if
615+
- another miner found a solution and is submitting it
616+
- the main loop is checking if a solution has been found
617+
- setWork has been called with a new work package
618+
*/
619+
620+
WriteGuard l(x_minerWork);
618621

619622
// check to see if the main loop is still processing a previous solution
620623
if (solutionMiner == -1)
@@ -624,10 +627,10 @@ class GenericFarm
624627
solution = _nonce;
625628
if (m_opMode == OperationMode::Solo)
626629
{
627-
challenge.clear();
630+
m_challenge.clear();
628631
for (auto const& m : m_miners)
629632
if (m != _m)
630-
m->setWork(challenge, target);
633+
m->setWork(m_challenge, m_target);
631634
shouldStop = true;
632635
} else
633636
shouldStop = false;
@@ -637,8 +640,6 @@ class GenericFarm
637640
shouldStop = m_opMode == OperationMode::Solo;
638641
}
639642

640-
x_minerWork.unlock();
641-
642643
return shouldStop;
643644

644645
}
@@ -682,8 +683,8 @@ class GenericFarm
682683
private:
683684
mutable SharedMutex x_minerWork;
684685
miners_t m_miners;
685-
h256 target;
686-
bytes challenge;
686+
h256 m_target;
687+
bytes m_challenge;
687688
OperationMode m_opMode;
688689

689690
std::atomic<bool> m_isMining = {false};

0 commit comments

Comments
 (0)