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

Add support for reloading the pool config file while miner is running #1655

Open
wants to merge 8 commits into
base: dev
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
4 changes: 4 additions & 0 deletions xmrstak/cli/cli-miner.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ int main(int argc, char *argv[])
printer::inst()->print_str("'h' - hashrate\n");
printer::inst()->print_str("'r' - results\n");
printer::inst()->print_str("'c' - connection\n");
printer::inst()->print_str("'p' - reload pools\n");
printer::inst()->print_str("-------------------------------------------------------------------\n");
printer::inst()->print_msg(L0, "Mining coin: %s", jconf::inst()->GetMiningCoin().c_str());

Expand Down Expand Up @@ -814,6 +815,9 @@ int main(int argc, char *argv[])
case 'c':
executor::inst()->push_event(ex_event(EV_USR_CONNSTAT));
break;
case 'p':
executor::inst()->push_event(ex_event(EV_USR_POOLRELOAD));
break;
default:
break;
}
Expand Down
Empty file modified xmrstak/jconf.cpp
100644 → 100755
Empty file.
Empty file modified xmrstak/jconf.hpp
100644 → 100755
Empty file.
125 changes: 75 additions & 50 deletions xmrstak/misc/executor.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "xmrstak/donate-level.hpp"
#include "xmrstak/version.hpp"
#include "xmrstak/http/webdesign.hpp"
#include "xmrstak/params.hpp"

#include <thread>
#include <string>
Expand Down Expand Up @@ -487,26 +488,8 @@ void disable_sigpipe()
inline void disable_sigpipe() {}
#endif

void executor::ex_main()
void executor::init_pools()
{
disable_sigpipe();

assert(1000 % iTickTime == 0);

xmrstak::miner_work oWork = xmrstak::miner_work();

// \todo collect all backend threads
pvThreads = xmrstak::BackendConnector::thread_starter(oWork);

if(pvThreads->size()==0)
{
printer::inst()->print_msg(L1, "ERROR: No miner backend enabled.");
win_exit();
}

telem = new xmrstak::telemetry(pvThreads->size());

set_timestamp();
size_t pc = jconf::inst()->GetPoolCount();
bool dev_tls = true;
bool already_have_cli_pool = false;
Expand Down Expand Up @@ -540,6 +523,7 @@ void executor::ex_main()
pools.emplace_back(i+1, cfg.sPoolAddr, cfg.sWalletAddr, cfg.sRigId, cfg.sPasswd, cfg.weight, false, cfg.tls, cfg.tls_fingerprint, cfg.nicehash);
}


if(!xmrstak::params::inst().poolURL.empty() && !already_have_cli_pool)
{
auto& params = xmrstak::params::inst();
Expand All @@ -554,38 +538,76 @@ void executor::ex_main()

switch(jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo())
{
case cryptonight_heavy:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8888", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:5555", "", "", "", 0.0, true, false, "", true);
break;
case cryptonight_heavy:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please remove all style changes that we can focus on the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is fixed now

if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8888", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:5555", "", "", "", 0.0, true, false, "", true);
break;

case cryptonight_monero:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8800", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:5500", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight_ipbc:
case cryptonight_aeon:
case cryptonight_lite:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", "", 0.0, true, false, "", true);
break;
case cryptonight_monero:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8800", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:5500", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight_ipbc:
case cryptonight_aeon:
case cryptonight_lite:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", "", 0.0, true, false, "", true);
break;

case cryptonight:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", "", 0.0, true, false, "", false);
break;

default:
break;
default:
break;
}

}


void executor::on_pools_reload()
{
if(!jconf::inst()->parse_config(xmrstak::params::inst().configFile.c_str(), xmrstak::params::inst().configFilePools.c_str()))
printer::inst()->print_msg(L1, "ERROR: Failed to reload pools");
else
{
pools.clear();
init_pools();
printer::inst()->print_msg(L1, "Pool list updated");
}
}


void executor::ex_main()
{
disable_sigpipe();

assert(1000 % iTickTime == 0);

xmrstak::miner_work oWork = xmrstak::miner_work();

// \todo collect all backend threads
pvThreads = xmrstak::BackendConnector::thread_starter(oWork);

if(pvThreads->size()==0)
{
printer::inst()->print_msg(L1, "ERROR: No miner backend enabled.");
win_exit();
}

telem = new xmrstak::telemetry(pvThreads->size());

set_timestamp();
init_pools();

ex_event ev;
std::thread clock_thd(&executor::ex_clock_thd, this);
Expand Down Expand Up @@ -631,7 +653,7 @@ void executor::ex_main()
break;

case EV_PERF_TICK:
for (i = 0; i < pvThreads->size(); i++)
for (size_t i = 0; i < pvThreads->size(); i++)
telem->push_perf_value(i, pvThreads->at(i)->iHashCount.load(std::memory_order_relaxed),
pvThreads->at(i)->iTimestamp.load(std::memory_order_relaxed));

Expand All @@ -640,8 +662,7 @@ void executor::ex_main()
double fHps = 0.0;
double fTelem;
bool normal = true;

for (i = 0; i < pvThreads->size(); i++)
for (size_t i = 0; i < pvThreads->size(); i++)
{
fTelem = telem->calc_telemetry_data(10000, i);
if(std::isnormal(fTelem))
Expand Down Expand Up @@ -678,6 +699,10 @@ void executor::ex_main()
push_timed_event(ex_event(EV_HASHRATE_LOOP), jconf::inst()->GetAutohashTime());
break;

case EV_USR_POOLRELOAD:
on_pools_reload();
break;

case EV_INVALID_VAL:
default:
assert(false);
Expand Down
2 changes: 2 additions & 0 deletions xmrstak/misc/executor.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class executor
void connect_to_pools(std::list<jpsock*>& eval_pools);
bool get_live_pools(std::vector<jpsock*>& eval_pools, bool is_dev);
void eval_pool_choice();
void on_pools_reload();
void init_pools();

inline size_t sec_to_ticks(size_t sec) { return sec * (1000 / iTickTime); }
};
Expand Down
3 changes: 2 additions & 1 deletion xmrstak/net/msgstruct.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ struct gpu_res_err
enum ex_event_name { EV_INVALID_VAL, EV_SOCK_READY, EV_SOCK_ERROR, EV_GPU_RES_ERROR,
EV_POOL_HAVE_JOB, EV_MINER_HAVE_RESULT, EV_PERF_TICK, EV_EVAL_POOL_CHOICE,
EV_USR_HASHRATE, EV_USR_RESULTS, EV_USR_CONNSTAT, EV_HASHRATE_LOOP,
EV_HTML_HASHRATE, EV_HTML_RESULTS, EV_HTML_CONNSTAT, EV_HTML_JSON };
EV_HTML_HASHRATE, EV_HTML_RESULTS, EV_HTML_CONNSTAT, EV_HTML_JSON,
EV_USR_POOLRELOAD};

/*
This is how I learned to stop worrying and love c++11 =).
Expand Down