Skip to content

Commit

Permalink
Reconnect when algo-perf or algo-min-time have been changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudz76 committed Aug 21, 2024
1 parent 9236bda commit a647d05
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/core/MoBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ void MoBenchmark::flush_perf() {
for (const Algorithm::Id algo : Algorithm::all()) algo_perf[algo] = 0.0f;
}

bool MoBenchmark::compare_perf(Config *previousConfig) {
// returns equivalent of == comparison
for (const Algorithm::Id algo : Algorithm::all()) {
if (algo_perf[algo] != previousConfig->benchmark().algo_perf[algo]) return false;
}
return true;
}

void MoBenchmark::read(const rapidjson::Value &value)
{
flush_perf();
Expand Down
2 changes: 2 additions & 0 deletions src/core/MoBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace xmrig {
class Controller;
class Miner;
class Job;
class Config;

class MoBenchmark : public IJobResultListener {

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

void start_perf(); // start benchmarks
bool compare_perf(Config *previousConfig);
void flush_perf();

bool isNewBenchRun() const { return m_isNewBenchRun; }
Expand Down
20 changes: 19 additions & 1 deletion src/net/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,27 @@ void xmrig::Network::onActive(IStrategy *strategy, IClient *client)

void xmrig::Network::onConfigChanged(Config *config, Config *previousConfig)
{
if (config->pools() == previousConfig->pools() || !config->pools().active()) {
if (!config->pools().active() ||
(config->pools() == previousConfig->pools()
# ifdef XMRIG_FEATURE_MO_BENCHMARK
&& config->algoMinTime() == previousConfig->algoMinTime()
&& config->benchmark().compare_perf(previousConfig)
# endif
)
) {
return;
}
if (config->pools() != previousConfig->pools()) {
LOG_WARN("%s " YELLOW("-> pools changed, reconnecting"), Tags::config());
}
# ifdef XMRIG_FEATURE_MO_BENCHMARK
if (config->algoMinTime() != previousConfig->algoMinTime()) {
LOG_WARN("%s " YELLOW("-> algo-min-time changed, reconnecting"), Tags::config());
}
if (!config->benchmark().compare_perf(previousConfig)) {
LOG_WARN("%s " YELLOW("-> algo-perf changed, reconnecting"), Tags::config());
}
# endif

m_strategy->stop();

Expand Down

0 comments on commit a647d05

Please sign in to comment.