Skip to content

Commit 63789ec

Browse files
committed
fix session stats reset on changed pool settings
1 parent 770cda9 commit 63789ec

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

main/stratum/stratum_manager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ void StratumManager::loadSettings(bool reconnect)
302302
m_stratumTasks[i]->triggerReconnect();
303303
}
304304

305+
// reset session stats for this pool
306+
resetPoolSessionStats(i);
307+
305308
// reset ping stats
306309
if (m_pingTasks[i]) {
307310
m_pingTasks[i]->reset();

main/stratum/stratum_manager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class StratumManager {
9898

9999
virtual int getPoolMode() = 0;
100100

101+
// reset stats for a single pool (called from loadSettings with mutex held)
102+
virtual void resetPoolSessionStats(int pool) {
103+
}
104+
101105
public:
102106
virtual void resetSessionStats() {
103107
PThreadGuard lock(m_mutex);

main/stratum/stratum_manager_dual_pool.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ class StratumManagerDualPool : public StratumManager {
9797
return (m_balance >= 50) ? m_networkDifficulty[0] : m_networkDifficulty[1];
9898
}
9999

100+
virtual void resetPoolSessionStats(int pool) override {
101+
StratumManager::resetPoolSessionStats(pool);
102+
m_accepted[pool] = 0;
103+
m_rejected[pool] = 0;
104+
m_bestSessionDiff[pool] = 0;
105+
suffixString(std::max(m_bestSessionDiff[0], m_bestSessionDiff[1]), m_bestSessionDiffString, DIFF_STRING_SIZE, 0);
106+
if (m_stratumTasks[pool]) m_stratumTasks[pool]->m_poolErrors = 0;
107+
}
108+
100109
virtual void resetSessionStats() override {
101110
PThreadGuard lock(m_mutex);
102-
m_foundBlocks = 0;
103111
for (int i = 0; i < 2; i++) {
104-
m_accepted[i] = 0;
105-
m_rejected[i] = 0;
106-
m_bestSessionDiff[i] = 0;
107-
suffixString(0, m_bestSessionDiffString, DIFF_STRING_SIZE, 0);
108-
if (m_stratumTasks[i]) m_stratumTasks[i]->m_poolErrors = 0;
112+
resetPoolSessionStats(i);
109113
}
110114
}
111115

main/stratum/stratum_manager_fallback.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,20 @@ class StratumManagerFallback : public StratumManager {
8080
return m_networkDifficulty;
8181
}
8282

83-
virtual void resetSessionStats() override {
84-
PThreadGuard lock(m_mutex);
85-
m_foundBlocks = 0;
83+
virtual void resetPoolSessionStats(int pool) override {
84+
StratumManager::resetPoolSessionStats(pool);
85+
// fallback mode shares a single counter for both pools
8686
m_accepted = 0;
8787
m_rejected = 0;
8888
m_bestSessionDiff = 0;
8989
suffixString(0, m_bestSessionDiffString, DIFF_STRING_SIZE, 0);
90+
if (m_stratumTasks[pool]) m_stratumTasks[pool]->m_poolErrors = 0;
91+
}
92+
93+
virtual void resetSessionStats() override {
94+
PThreadGuard lock(m_mutex);
9095
for (int i = 0; i < 2; i++) {
91-
if (m_stratumTasks[i]) m_stratumTasks[i]->m_poolErrors = 0;
96+
resetPoolSessionStats(i);
9297
}
9398
}
9499

main/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void System::task() {
290290
uint32_t foundBlocks = STRATUM_MANAGER->getFoundBlocks();
291291

292292
// trigger the overlay only once when block is found
293-
if (foundBlocks != lastFoundBlocks && foundBlocks) {
293+
if (foundBlocks > lastFoundBlocks) {
294294
m_display->showFoundBlockOverlay();
295295
}
296296
lastFoundBlocks = foundBlocks;

0 commit comments

Comments
 (0)