@@ -204,12 +204,12 @@ class GenericFarm
204
204
<< " , target=" << std::hex << std::setw (16 ) << std::setfill (' 0' ) << upper64OfHash (_target);
205
205
206
206
WriteGuard l (x_minerWork);
207
- if (_challenge == challenge && _target == target )
207
+ if (_challenge == m_challenge && _target == m_target )
208
208
return ;
209
- challenge = _challenge;
210
- target = _target;
209
+ m_challenge = _challenge;
210
+ m_target = _target;
211
211
for (auto const & m: m_miners)
212
- m->setWork (challenge, target );
212
+ m->setWork (m_challenge, m_target );
213
213
}
214
214
215
215
@@ -227,7 +227,7 @@ class GenericFarm
227
227
m_hashRates->init ();
228
228
// can't call setWork until we've initialized the hash rates
229
229
// for (auto const& m : m_miners)
230
- // m->setWork_token(challenge, target );
230
+ // m->setWork_token(m_challenge, m_target );
231
231
232
232
LogF << " Trace: GenericFarm.start [exit]" ;
233
233
}
@@ -605,16 +605,19 @@ class GenericFarm
605
605
*----------------------------------------------------------------------------------*/
606
606
bool submitProof (h256 _nonce, Miner* _m)
607
607
{
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
609
609
bool shouldStop = false ;
610
610
611
611
LogF << " Trace: GenericFarm.submitProof - nonce = " << _nonce.hex ().substr (0 , 8 ) << " , miner = " << _m->index ();
612
612
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);
618
621
619
622
// check to see if the main loop is still processing a previous solution
620
623
if (solutionMiner == -1 )
@@ -624,10 +627,10 @@ class GenericFarm
624
627
solution = _nonce;
625
628
if (m_opMode == OperationMode::Solo)
626
629
{
627
- challenge .clear ();
630
+ m_challenge .clear ();
628
631
for (auto const & m : m_miners)
629
632
if (m != _m)
630
- m->setWork (challenge, target );
633
+ m->setWork (m_challenge, m_target );
631
634
shouldStop = true ;
632
635
} else
633
636
shouldStop = false ;
@@ -637,8 +640,6 @@ class GenericFarm
637
640
shouldStop = m_opMode == OperationMode::Solo;
638
641
}
639
642
640
- x_minerWork.unlock ();
641
-
642
643
return shouldStop;
643
644
644
645
}
@@ -682,8 +683,8 @@ class GenericFarm
682
683
private:
683
684
mutable SharedMutex x_minerWork;
684
685
miners_t m_miners;
685
- h256 target ;
686
- bytes challenge ;
686
+ h256 m_target ;
687
+ bytes m_challenge ;
687
688
OperationMode m_opMode;
688
689
689
690
std::atomic<bool > m_isMining = {false };
0 commit comments