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

Reconnect #1135

Merged
merged 13 commits into from
May 25, 2018
Prev Previous commit
Next Next commit
Add delay to reconnection on pool switching
AndreaLanfranchi committed May 22, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 5681a7cc02bfda538baaab7f577212951e956db7
15 changes: 6 additions & 9 deletions libpoolprotocols/PoolManager.cpp
Original file line number Diff line number Diff line change
@@ -188,29 +188,26 @@ void PoolManager::workLoop()
// Rotate connections if above max attempts threshold
if (m_connectionAttempt >= m_maxConnectionAttempts) {

unsigned lastConnectionIdx = m_activeConnectionIdx;

m_connectionAttempt = 0;
m_activeConnectionIdx++;
if (m_activeConnectionIdx == m_connections.size()) {
m_activeConnectionIdx = 0;
}

if (lastConnectionIdx != m_activeConnectionIdx) {

// Stop mining if applicable as we're switching
if (m_farm.isMining()) {
cnote << "Shutting down miners...";
m_farm.stop();
}
// Stop 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";
}

}



}

if (m_connections[m_activeConnectionIdx].Host() != "exit") {