Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnect when algo-perf or algo-min-time have been changed #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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