diff options
author | fireice-uk <fireice2@o2.pl> | 2017-02-12 14:14:27 +0000 |
---|---|---|
committer | fireice-uk <fireice2@o2.pl> | 2017-02-12 14:14:27 +0000 |
commit | 1b4f0dd57be74bcd5e724d7910243a5c6712e7d8 (patch) | |
tree | c8cf3f4560809a53718fa3fabe88e0a9aa509aa2 | |
parent | 433db1917e95568d56802d73213a1f4ab6782a0c (diff) | |
download | xmr-stak-1b4f0dd57be74bcd5e724d7910243a5c6712e7d8.zip xmr-stak-1b4f0dd57be74bcd5e724d7910243a5c6712e7d8.tar.gz |
Giveup limit
-rw-r--r-- | config.txt | 3 | ||||
-rw-r--r-- | executor.cpp | 14 | ||||
-rw-r--r-- | executor.h | 2 | ||||
-rw-r--r-- | jconf.cpp | 15 | ||||
-rw-r--r-- | jconf.h | 1 |
5 files changed, 31 insertions, 4 deletions
@@ -110,9 +110,12 @@ * call_timeout - How long should we wait for a response from the server before we assume it is dead and drop the connection.
* retry_time - How long should we wait before another connection attempt.
* Both values are in seconds.
+ * giveup_limit - Limit how many times we try to reconnect to the pool. Zero means no limit. Note that stak miners
+ * don't mine while the connection is lost, so your computer's power usage goes down to idle.
*/
"call_timeout" : 10,
"retry_time" : 10,
+"giveup_limit" : 0,
/*
* Output control.
diff --git a/executor.cpp b/executor.cpp index aa9588d..7697a2f 100644 --- a/executor.cpp +++ b/executor.cpp @@ -96,8 +96,17 @@ void executor::ex_clock_thd() void executor::sched_reconnect() { + iReconnectAttempts++; + size_t iLimit = jconf::inst()->GetGiveUpLimit(); + if(iLimit != 0 && iReconnectAttempts > iLimit) + { + printer::inst()->print_msg(L0, "Give up limit reached. Exitting."); + exit(0); + } + long long unsigned int rt = jconf::inst()->GetNetRetry(); - printer::inst()->print_msg(L1, "Pool connection lost. Waiting %lld s before retry.", rt); + printer::inst()->print_msg(L1, "Pool connection lost. Waiting %lld s before retry (attempt %llu).", + rt, int_port(iReconnectAttempts)); auto work = minethd::miner_work(); minethd::switch_work(work); @@ -178,7 +187,10 @@ void executor::on_sock_ready(size_t pool_id) } } else + { + iReconnectAttempts = 0; reset_stats(); + } } void executor::on_sock_error(size_t pool_id, std::string&& sError) @@ -81,6 +81,8 @@ private: std::promise<void> httpReady; std::mutex httpMutex; + size_t iReconnectAttempts = 0; + struct sck_error_log { std::chrono::system_clock::time_point time; @@ -38,7 +38,8 @@ using namespace rapidjson; * This enum needs to match index in oConfigValues, otherwise we will get a runtime error */ enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, bNiceHashMode, bTlsMode, bTlsSecureAlgo, sTlsFingerprint, - sPoolAddr, sWalletAddr, sPoolPwd, iCallTimeout, iNetRetry, iVerboseLevel, iAutohashTime, iHttpdPort, bPreferIpv4 }; + sPoolAddr, sWalletAddr, sPoolPwd, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime, iHttpdPort, + bPreferIpv4 }; struct configVal { configEnum iName; @@ -60,6 +61,7 @@ configVal oConfigValues[] = { { sPoolPwd, "pool_password", kStringType }, { iCallTimeout, "call_timeout", kNumberType }, { iNetRetry, "retry_time", kNumberType }, + { iGiveUpLimit, "giveup_limit", kNumberType }, { iVerboseLevel, "verbose_level", kNumberType }, { iAutohashTime, "h_print_time", kNumberType }, { iHttpdPort, "httpd_port", kNumberType }, @@ -207,6 +209,11 @@ uint64_t jconf::GetNetRetry() return prv->configValues[iNetRetry]->GetUint64(); } +uint64_t jconf::GetGiveUpLimit() +{ + return prv->configValues[iGiveUpLimit]->GetUint64(); +} + uint64_t jconf::GetVerboseLevel() { return prv->configValues[iVerboseLevel]->GetUint64(); @@ -378,10 +385,12 @@ bool jconf::parse_config(const char* sFilename) return false; } - if(!prv->configValues[iCallTimeout]->IsUint64() || !prv->configValues[iNetRetry]->IsUint64()) + if(!prv->configValues[iCallTimeout]->IsUint64() || + !prv->configValues[iNetRetry]->IsUint64() || + !prv->configValues[iGiveUpLimit]->IsUint64()) { printer::inst()->print_msg(L0, - "Invalid config file. call_timeout and retry_time need to be positive integers."); + "Invalid config file. call_timeout, retry_time and giveup_limit need to be positive integers."); return false; } @@ -45,6 +45,7 @@ public: uint64_t GetCallTimeout(); uint64_t GetNetRetry(); + uint64_t GetGiveUpLimit(); uint16_t GetHttpdPort(); |