From 961de0f4855bda890a48090c17ffd213bdab4ef0 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Wed, 6 Dec 2017 22:24:33 +0100 Subject: fix broken pool option overwrite via CLI fix #340 With #90 the option to overwrite the pool settings via CLI options is broken. This pull request will allow to overwrite the options of the pool with the highest weighting. --- xmrstak/misc/executor.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'xmrstak/misc/executor.cpp') diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index c500b21..6f34d80 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -528,6 +528,30 @@ void executor::ex_main() pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", 0.0, true, false, "", true); } + /* find the pool with the highest weighting to allow overwriting of the + * pool settings via command line options. + */ + std::vector sorted_pools; + sorted_pools.reserve(pools.size()); + for(jpsock& pool : pools) + sorted_pools.emplace_back(&pool); + std::sort(sorted_pools.begin(), sorted_pools.end(), [](jpsock* a, jpsock* b) { return b->get_pool_weight(true) < a->get_pool_weight(true); }); + + // overwrite pool address if cli option is used + auto& poolURL = xmrstak::params::inst().poolURL; + if(!poolURL.empty()) + { + sorted_pools[0]->set_pool_addr(poolURL.c_str()); + } + // overwrite user pool login name if cli option is used + auto& poolUsername = xmrstak::params::inst().poolUsername; + if(!poolUsername.empty()) + sorted_pools[0]->set_user_login(poolUsername.c_str()); + // overwrite user pool login password if cli option is used + auto& poolPasswd = xmrstak::params::inst().poolPasswd; + if(!poolPasswd.empty()) + sorted_pools[0]->set_user_passwd(poolPasswd.c_str()); + ex_event ev; std::thread clock_thd(&executor::ex_clock_thd, this); -- cgit v1.1