-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathstratum_manager_fallback.h
More file actions
116 lines (88 loc) · 2.88 KB
/
Copy pathstratum_manager_fallback.h
File metadata and controls
116 lines (88 loc) · 2.88 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
#pragma once
#include "stratum_manager.h"
#include "utils.h"
class StratumManagerFallback : public StratumManager {
friend StratumTaskBase; ///< Allows StratumTaskBase to access private members
protected:
int m_selected = 0;
uint64_t m_accepted = 0;
uint64_t m_rejected = 0;
uint32_t m_poolDifficulty = 0;
double m_networkDifficulty = 0;
uint64_t m_bestSessionDiff = 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 = diff;
};
virtual void setNetworkDifficulty(int pool, uint32_t nbits) {
if (nbits != 0) {
m_networkDifficulty = calculateNetworkDifficulty(nbits);
}
}
virtual void acceptedShare(int pool)
{
m_accepted++;
}
virtual void rejectedShare(int pool)
{
m_rejected++;
}
virtual int getPoolMode() {
return 0;
}
public:
StratumManagerFallback();
virtual const char *getCurrentPoolHost();
virtual int getCurrentPoolPort();
virtual int getNextActivePool();
bool isFallback() const override { return true; }
virtual uint32_t selectAsicDiff(int pool, uint32_t poolDiff);
virtual void checkForBestDiff(int pool, double diff, uint32_t nbits);
virtual void getManagerInfoJson(JsonObject &obj);
virtual void loadSettings();
virtual void saveSettings(const JsonDocument &doc);
// aggregated compatibility methos
virtual uint64_t getSharesAccepted() {
return m_accepted;
};
virtual uint64_t getSharesRejected() {
return m_rejected;
}
virtual uint32_t getPoolDifficulty() {
return m_poolDifficulty;
};
virtual double getNetworkDifficulty() {
return m_networkDifficulty;
}
virtual void resetPoolSessionStats(int pool) override {
StratumManager::resetPoolSessionStats(pool);
// fallback mode shares a single counter for both pools
m_accepted = 0;
m_rejected = 0;
m_bestSessionDiff = 0;
suffixString(0, 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 int getPoolErrors() {
return m_stratumTasks[0]->m_poolErrors + m_stratumTasks[1]->m_poolErrors;
}
virtual bool isUsingFallback()
{
return m_selected == StratumManager::Selected::SECONDARY;
}
virtual int getCompatPingPoolIndex() {
return m_selected;
}
virtual uint64_t getBestSessionDiff() {
return m_bestSessionDiff;
}
};