Skip to content

Commit

Permalink
pause the workers if reach maxSubmit count.
Browse files Browse the repository at this point in the history
  • Loading branch information
deepgully committed Jan 23, 2019
1 parent 6eef912 commit ce97090
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libethash-cl/CLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void CLMiner::workLoop()

// Wait for work or 3 seconds (whichever the first)
const WorkPackage w = work();
if (!w)
if (!w || paused())
{
boost::system_time const timeout =
boost::get_system_time() + boost::posix_time::seconds(3);
Expand Down
2 changes: 1 addition & 1 deletion libethash-cuda/CUDAMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void CUDAMiner::workLoop()
{
// Wait for work or 3 seconds (whichever the first)
const WorkPackage w = work();
if (!w)
if (!w || paused())
{
boost::system_time const timeout =
boost::get_system_time() + boost::posix_time::seconds(3);
Expand Down
12 changes: 12 additions & 0 deletions libethcore/Farm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ void Farm::shuffle()

void Farm::setWork(WorkPackage const& _newWp)
{
if (paused())
{
resume();
}
m_submitted_count = 0;

// Set work to each miner giving it's own starting nonce
Guard l(x_minerWork);

Expand Down Expand Up @@ -490,6 +496,11 @@ void Farm::setTStartTStop(unsigned tstart, unsigned tstop)

void Farm::submitProof(Solution const& _s)
{
if ((m_Settings.maxSubmitCount >= 0) && (m_submitted_count++ >= m_Settings.maxSubmitCount))
{
pause();
return;
}
g_io_service.post(m_io_strand.wrap(boost::bind(&Farm::submitProofAsync, this, _s)));
}

Expand All @@ -500,6 +511,7 @@ void Farm::submitProofAsync(Solution const& _s)
Result r = EthashAux::eval(_s.work.epoch, _s.work.header, _s.nonce);
if (r.value > _s.work.boundary)
{
m_submitted_count = 0;
accountSolution(_s.midx, SolutionAccountingEnum::Failed);
cwarn << "GPU " << _s.midx
<< " gave incorrect result. Lower overclocking values if it happens frequently.";
Expand Down
1 change: 1 addition & 0 deletions libethcore/Farm.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class Farm : public FarmFace
// before it consumes the whole 2^32 segment
uint64_t m_nonce_scrambler;
unsigned int m_nonce_segment_with = 32;
std::atomic<int> m_submitted_count = {0};

// Wrappers for hardware monitoring libraries and their mappers
wrap_nvml_handle* nvmlh = nullptr;
Expand Down

0 comments on commit ce97090

Please sign in to comment.