summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfireice-uk <fireice2@o2.pl>2017-02-12 14:14:27 +0000
committerfireice-uk <fireice2@o2.pl>2017-02-12 14:14:27 +0000
commit1b4f0dd57be74bcd5e724d7910243a5c6712e7d8 (patch)
treec8cf3f4560809a53718fa3fabe88e0a9aa509aa2
parent433db1917e95568d56802d73213a1f4ab6782a0c (diff)
downloadxmr-stak-1b4f0dd57be74bcd5e724d7910243a5c6712e7d8.zip
xmr-stak-1b4f0dd57be74bcd5e724d7910243a5c6712e7d8.tar.gz
Giveup limit
-rw-r--r--config.txt3
-rw-r--r--executor.cpp14
-rw-r--r--executor.h2
-rw-r--r--jconf.cpp15
-rw-r--r--jconf.h1
5 files changed, 31 insertions, 4 deletions
diff --git a/config.txt b/config.txt
index f88af56..eba9653 100644
--- a/config.txt
+++ b/config.txt
@@ -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)
diff --git a/executor.h b/executor.h
index 63459b9..7bde3b5 100644
--- a/executor.h
+++ b/executor.h
@@ -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;
diff --git a/jconf.cpp b/jconf.cpp
index 5879042..532ff7c 100644
--- a/jconf.cpp
+++ b/jconf.cpp
@@ -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;
}
diff --git a/jconf.h b/jconf.h
index 270eaac..ad556ec 100644
--- a/jconf.h
+++ b/jconf.h
@@ -45,6 +45,7 @@ public:
uint64_t GetCallTimeout();
uint64_t GetNetRetry();
+ uint64_t GetGiveUpLimit();
uint16_t GetHttpdPort();
OpenPOWER on IntegriCloud