-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathstratum_manager_dual_pool.h
More file actions
127 lines (95 loc) · 3.36 KB
/
Copy pathstratum_manager_dual_pool.h
File metadata and controls
127 lines (95 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
#include "stratum_manager.h"
#include "utils.h"
class StratumManagerDualPool : public StratumManager {
friend StratumTaskBase; ///< Allows StratumTaskBase to access private members
protected:
int m_balance = 50;
int32_t m_error_accum = 0;
uint64_t m_accepted[2]{};
uint64_t m_rejected[2]{};
uint64_t m_bestSessionDiff[2]{};
bool m_poolDiffErr[2]{};
uint32_t m_poolDifficulty[2]{0};
double m_networkDifficulty[2]{0};
virtual void reconnectTimerCallback(int index);
virtual void connectedCallback(int index);
virtual void disconnectedCallback(int index);
virtual bool acceptsNotifyFrom(int pool);
virtual void setPoolDifficulty(int pool, uint32_t diff) {
m_poolDifficulty[pool] = diff;
};
virtual void setNetworkDifficulty(int pool, uint32_t nbits) {
if (pool >= 0 && pool < 2 && nbits != 0) {
m_networkDifficulty[pool] = calculateNetworkDifficulty(nbits);
}
}
virtual void acceptedShare(int pool)
{
m_accepted[pool]++;
}
virtual void rejectedShare(int pool)
{
m_rejected[pool]++;
}
virtual int getPoolMode() {
return 1;
}
public:
StratumManagerDualPool();
bool getPoolDiffErr(int i) {
if (i < 0 || i >= 2) {
return false;
}
return m_poolDiffErr[i];
}
virtual const char *getPoolHost(int pool);
virtual int getPoolPort(int pool);
virtual uint32_t selectAsicDiff(int pool, uint32_t poolDiff);
virtual int getNextActivePool();
bool isDualPool() const override { return true; }
virtual void checkForBestDiff(int pool, double diff, uint32_t nbits);
virtual void getManagerInfoJson(JsonObject &obj);
virtual void loadSettings();
virtual void saveSettings(const JsonDocument &doc);
virtual uint64_t getSharesAccepted(int pool);
virtual uint64_t getSharesRejected(int pool);
float getActivePoolHashrate(int pool);
int getActivePoolBalance(int pool);
// aggregated
virtual uint64_t getSharesAccepted() {
return m_accepted[0] + m_accepted[1];
}
virtual uint64_t getSharesRejected() {
return m_rejected[0] + m_rejected[1];
}
virtual uint32_t getPoolDifficulty() {
return (m_balance >= 50) ? m_poolDifficulty[0] : m_poolDifficulty[1];
};
virtual double getNetworkDifficulty() {
return (m_balance >= 50) ? m_networkDifficulty[0] : m_networkDifficulty[1];
}
virtual void resetPoolSessionStats(int pool) override {
StratumManager::resetPoolSessionStats(pool);
m_accepted[pool] = 0;
m_rejected[pool] = 0;
m_bestSessionDiff[pool] = 0;
suffixString(std::max(m_bestSessionDiff[0], m_bestSessionDiff[1]), m_bestSessionDiffString, DIFF_STRING_SIZE, 0);
if (m_stratumTasks[pool]) m_stratumTasks[pool]->m_poolErrors = 0;
}
virtual void resetSessionStats() override {
PThreadGuard lock(m_mutex);
for (int i = 0; i < 2; i++) {
resetPoolSessionStats(i);
}
}
virtual uint64_t getBestSessionDiff() {
return std::max(m_bestSessionDiff[0], m_bestSessionDiff[1]);
}
virtual int getPoolErrors() {
return m_stratumTasks[0]->m_poolErrors + m_stratumTasks[1]->m_poolErrors;
}
virtual int getCompatPingPoolIndex() {
return (m_balance >= 50) ? 0 : 1;
}
};