diff options
-rw-r--r-- | xmrstak/cli/cli-miner.cpp | 43 | ||||
-rw-r--r-- | xmrstak/config.tpl | 6 | ||||
-rw-r--r-- | xmrstak/jconf.cpp | 40 | ||||
-rw-r--r-- | xmrstak/jconf.hpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/executor.cpp | 21 | ||||
-rw-r--r-- | xmrstak/params.hpp | 2 |
6 files changed, 107 insertions, 7 deletions
diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index 8939803..054e6db 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -62,8 +62,11 @@ void help() cout<<"Usage: "<<params::inst().binaryName<<" [OPTION]..."<<endl; cout<<" "<<endl; - cout<<" -c, --config FILE common miner configuration file"<<endl; cout<<" -h, --help show this help"<<endl; + cout<<" -c, --config FILE common miner configuration file"<<endl; +#if (!defined(CONF_NO_AEON)) && (!defined(CONF_NO_XMR)) + cout<<" --currency NAME currency to mine: xmr or aeon"<<endl; +#endif #ifndef CONF_NO_CPU cout<<" --noCPU disable the CPU miner backend"<<endl; cout<<" --cpu FILE CPU backend miner config file"<<endl; @@ -168,6 +171,17 @@ int main(int argc, char *argv[]) } params::inst().configFileNVIDIA = argv[i]; } + else if(opName.compare("--currency") == 0) + { + ++i; + if( i >=argc ) + { + printer::inst()->print_msg(L0, "No argument for parameter '--currency' given"); + win_exit(); + return 1; + } + params::inst().currency = argv[i]; + } else if(opName.compare("-o") == 0 || opName.compare("--url") == 0) { ++i; @@ -230,10 +244,30 @@ int main(int argc, char *argv[]) ; configEditor configTpl{}; configTpl.set(std::string(tpl)); + std::cout<<"Please enter:"<<std::endl; + auto& currency = params::inst().currency; + if(currency.empty()) + { + std::string tmp; +#if defined(CONF_NO_AEON) + tmp = "xmr"; +#elif defined(CONF_NO_XMR) + tmp = "aeon"; +#endif + while(tmp.compare("xmr") != 0 && tmp.compare("aeon") != 0) + { + std::cout<<"- currency: 'xmr' or 'aeon'"<<std::endl; + std::cin >> tmp; + } + currency = tmp; + } auto& pool = params::inst().poolURL; if(pool.empty()) { - std::cout<<"Please enter:\n- pool address: e.g. pool.usxmrpool.com:3333"<<std::endl; + if(currency.compare("xmr") != 0) + std::cout<<"- pool address: e.g. pool.usxmrpool.com:3333"<<std::endl; + else + std::cout<<"- pool address: e.g. mine.aeon-pool.com:5555"<<std::endl; std::cin >> pool; } auto& userName = params::inst().poolUsername; @@ -253,6 +287,7 @@ int main(int argc, char *argv[]) configTpl.replace("POOLURL", pool); configTpl.replace("POOLUSER", userName); configTpl.replace("POOLPASSWD", passwd); + configTpl.replace("CURRENCY", currency); configTpl.write(params::inst().configFile); std::cout<<"Configuration stored in file '"<<params::inst().configFile<<"'"<<std::endl; } @@ -298,6 +333,10 @@ int main(int argc, char *argv[]) printer::inst()->print_str("'r' - results\n"); printer::inst()->print_str("'c' - connection\n"); printer::inst()->print_str("-------------------------------------------------------------------\n"); + if(::jconf::inst()->IsCurrencyXMR()) + printer::inst()->print_msg(L0,"Start mining: XMR"); + else + printer::inst()->print_msg(L0,"Start mining: AEON"); if(strlen(jconf::inst()->GetOutputFile()) != 0) printer::inst()->open_logfile(jconf::inst()->GetOutputFile()); diff --git a/xmrstak/config.tpl b/xmrstak/config.tpl index 60d85cd..5567841 100644 --- a/xmrstak/config.tpl +++ b/xmrstak/config.tpl @@ -11,6 +11,12 @@ R"===( "pool_password" : "POOLPASSWD", /* + * currency to mine + * allowed values: 'xmr' or 'aeon' + */ +"currency" : "CURRENCY", + +/* * Network timeouts. * Because of the way this client is written it doesn't need to constantly talk (keep-alive) to the server to make * sure it is there. We detect a buggy / overloaded server by the call timeout. The default values will be ok for diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp index c033e66..fce1751 100644 --- a/xmrstak/jconf.cpp +++ b/xmrstak/jconf.cpp @@ -46,7 +46,7 @@ using namespace rapidjson; * This enum needs to match index in oConfigValues, otherwise we will get a runtime error */ enum configEnum { - bTlsMode, bTlsSecureAlgo, sTlsFingerprint, sPoolAddr, sWalletAddr, sPoolPwd, + bTlsMode, bTlsSecureAlgo, sTlsFingerprint, sPoolAddr, sWalletAddr, sPoolPwd,sCurrency, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime, bDaemonMode, sOutputFile, iHttpdPort, bPreferIpv4, bNiceHashMode, bAesOverride, sUseSlowMem }; @@ -65,6 +65,7 @@ configVal oConfigValues[] = { { sPoolAddr, "pool_address", kStringType }, { sWalletAddr, "wallet_address", kStringType }, { sPoolPwd, "pool_password", kStringType }, + { sCurrency, "currency", kStringType }, { iCallTimeout, "call_timeout", kNumberType }, { iNetRetry, "retry_time", kNumberType }, { iGiveUpLimit, "giveup_limit", kNumberType }, @@ -150,6 +151,43 @@ const char* jconf::GetWalletAddress() return poolUsername.c_str(); } +const std::string jconf::GetCurrency() +{ + auto& currency = xmrstak::params::inst().currency; + if(currency.empty()) + currency = prv->configValues[sCurrency]->GetString(); + if( +#ifndef CONF_NO_XMR + currency.compare("xmr") != 0 +#else + true +#endif + && +#ifndef CONF_NO_AEON + currency.compare("aeon") != 0 +#else + true +#endif + ) + { + printer::inst()->print_msg(L0, "ERROR: Wrong currency selected - '%s'.", currency.c_str()); + win_exit(); + } + return currency; +} + +bool jconf::IsCurrencyXMR() +{ + if(::jconf::inst()->GetCurrency().compare("xmr") == 0) + { + return true; + } + else + { + return false; + } +} + bool jconf::PreferIpv4() { return prv->configValues[bPreferIpv4]->GetBool(); diff --git a/xmrstak/jconf.hpp b/xmrstak/jconf.hpp index 688ffe1..96c7691 100644 --- a/xmrstak/jconf.hpp +++ b/xmrstak/jconf.hpp @@ -41,6 +41,8 @@ public: const char* GetPoolAddress(); const char* GetPoolPwd(); const char* GetWalletAddress(); + const std::string GetCurrency(); + bool IsCurrencyXMR(); uint64_t GetVerboseLevel(); uint64_t GetAutohashTime(); diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index 7fc46e4..885961a 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -21,6 +21,7 @@ * */ +#include "../jconf.hpp" #include "executor.hpp" #include "xmrstak/net/jpsock.hpp" @@ -183,8 +184,16 @@ void executor::on_sock_ready(size_t pool_id) if(pool_id == dev_pool_id) { - if(!pool->cmd_login("", "")) - pool->disconnect(); + if(::jconf::inst()->IsCurrencyXMR()) + { + if(!pool->cmd_login("", "")) + pool->disconnect(); + } + else + { + if(!pool->cmd_login("WmsvqXDu7Fw5eAEZr1euJH3ycad55NxFd82PfhLR9Zi1Nq5S74zk63EA8fyMS8BQNR94os9N9aah87inKkumNJ7G2d7qTpRLN", "x")) + pool->disconnect(); + } current_pool_id = dev_pool_id; printer::inst()->print_msg(L1, "Dev pool logged in. Switching work."); @@ -352,8 +361,12 @@ void executor::on_switch_pool(size_t pool_id) // If it fails, it fails, we carry on on the usr pool // as we never receive further events printer::inst()->print_msg(L1, "Connecting to dev pool..."); - const char* dev_pool_addr = jconf::inst()->GetTlsSetting() ? "donate.xmr-stak.net:6666" : "donate.xmr-stak.net:3333"; - if(!pool->connect(dev_pool_addr, error)) + std::string dev_pool_addr; + if(::jconf::inst()->IsCurrencyXMR()) + dev_pool_addr = jconf::inst()->GetTlsSetting() ? "donate.xmr-stak.net:6666" : "donate.xmr-stak.net:3333"; + else + dev_pool_addr = jconf::inst()->GetTlsSetting() ? "mine.aeon-pool.com:443" : "mine.aeon-pool.com:5555"; + if(!pool->connect(dev_pool_addr.c_str(), error)) printer::inst()->print_msg(L1, "Error connecting to dev pool. Staying with user pool."); } else diff --git a/xmrstak/params.hpp b/xmrstak/params.hpp index dddf82e..6127212 100644 --- a/xmrstak/params.hpp +++ b/xmrstak/params.hpp @@ -28,6 +28,8 @@ struct params std::string poolPasswd; std::string poolUsername; + std::string currency; + std::string configFile; std::string configFileAMD; std::string configFileNVIDIA; |