Skip to content

Commit

Permalink
Merge pull request ethereum-mining#1528 from ethereum-mining/Generate…
Browse files Browse the repository at this point in the history
…DAGOnlyOnChange

Generate DAG only on change - even when switching connection
  • Loading branch information
MariusVanDerWijden committed Aug 30, 2018
2 parents 885626c + 674f6c7 commit a19963c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
3 changes: 0 additions & 3 deletions libethcore/Farm.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ class Farm : public FarmFace

m_isMining.store(true, std::memory_order_relaxed);
m_lastSealer = _sealer;
b_lastMixed = mixed;


return true;
}
Expand Down Expand Up @@ -536,7 +534,6 @@ class Farm : public FarmFace

std::map<std::string, SealerDescriptor> m_sealers;
std::string m_lastSealer;
bool b_lastMixed = false;

boost::asio::io_service::strand m_io_strand;
boost::asio::deadline_timer m_collectTimer;
Expand Down
25 changes: 9 additions & 16 deletions libpoolprotocols/PoolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,11 @@ void PoolManager::workLoop()
m_activeConnectionIdx = 0;
}

// Stop mining if applicable as we're switching
// Suspend mining if applicable as we're switching
if (m_farm.isMining())
{
cnote << "Shutting down miners...";
m_farm.stop();

// Give some time to mining threads to shutdown
for (auto i = 4; --i; this_thread::sleep_for(chrono::seconds(1)))
{
cnote << "Retrying in " << i << "... \r";
}
cnote << "Suspend mining due connection change...";
m_farm.setWork({}); /* suspend by setting empty work package */
}
}

Expand Down Expand Up @@ -336,17 +330,16 @@ void PoolManager::setActiveConnection(unsigned int idx)
// Sets the active connection to the requested index
if (idx != m_activeConnectionIdx)
{
m_activeConnectionIdx = idx;
m_connectionAttempt = 0;
p_client->disconnect();

// Stop mining if applicable as we're switching
// Suspend mining if applicable as we're switching
if (m_farm.isMining())
{
cnote << "Shutting down miners...";
m_farm.stop();
cnote << "Suspend mining due connection change...";
m_farm.setWork({}); /* suspend by setting empty work package */
}

m_activeConnectionIdx = idx;
m_connectionAttempt = 0;
p_client->disconnect();
}
}

Expand Down

0 comments on commit a19963c

Please sign in to comment.