Skip to content

Commit a647d05

Browse files
committed
Reconnect when algo-perf or algo-min-time have been changed
1 parent 9236bda commit a647d05

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/core/MoBenchmark.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ void MoBenchmark::flush_perf() {
7979
for (const Algorithm::Id algo : Algorithm::all()) algo_perf[algo] = 0.0f;
8080
}
8181

82+
bool MoBenchmark::compare_perf(Config *previousConfig) {
83+
// returns equivalent of == comparison
84+
for (const Algorithm::Id algo : Algorithm::all()) {
85+
if (algo_perf[algo] != previousConfig->benchmark().algo_perf[algo]) return false;
86+
}
87+
return true;
88+
}
89+
8290
void MoBenchmark::read(const rapidjson::Value &value)
8391
{
8492
flush_perf();

src/core/MoBenchmark.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace xmrig {
3131
class Controller;
3232
class Miner;
3333
class Job;
34+
class Config;
3435

3536
class MoBenchmark : public IJobResultListener {
3637

@@ -95,6 +96,7 @@ class MoBenchmark : public IJobResultListener {
9596
void set_controller(std::shared_ptr<Controller> controller) { m_controller = controller.get(); }
9697

9798
void start_perf(); // start benchmarks
99+
bool compare_perf(Config *previousConfig);
98100
void flush_perf();
99101

100102
bool isNewBenchRun() const { return m_isNewBenchRun; }

src/net/Network.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,27 @@ void xmrig::Network::onActive(IStrategy *strategy, IClient *client)
149149

150150
void xmrig::Network::onConfigChanged(Config *config, Config *previousConfig)
151151
{
152-
if (config->pools() == previousConfig->pools() || !config->pools().active()) {
152+
if (!config->pools().active() ||
153+
(config->pools() == previousConfig->pools()
154+
# ifdef XMRIG_FEATURE_MO_BENCHMARK
155+
&& config->algoMinTime() == previousConfig->algoMinTime()
156+
&& config->benchmark().compare_perf(previousConfig)
157+
# endif
158+
)
159+
) {
153160
return;
154161
}
162+
if (config->pools() != previousConfig->pools()) {
163+
LOG_WARN("%s " YELLOW("-> pools changed, reconnecting"), Tags::config());
164+
}
165+
# ifdef XMRIG_FEATURE_MO_BENCHMARK
166+
if (config->algoMinTime() != previousConfig->algoMinTime()) {
167+
LOG_WARN("%s " YELLOW("-> algo-min-time changed, reconnecting"), Tags::config());
168+
}
169+
if (!config->benchmark().compare_perf(previousConfig)) {
170+
LOG_WARN("%s " YELLOW("-> algo-perf changed, reconnecting"), Tags::config());
171+
}
172+
# endif
155173

156174
m_strategy->stop();
157175

0 commit comments

Comments
 (0)