From 83762e5bedfef2d0aa25552bc8aeae7afb8f2b5e Mon Sep 17 00:00:00 2001 From: fireice-uk Date: Fri, 26 May 2017 19:36:38 +0100 Subject: [PATCH] daemon mode feature --- cli-miner.cpp | 2 +- config.txt | 8 ++++++++ executor.cpp | 1 - executor.h | 6 +++--- jconf.cpp | 8 +++++++- jconf.h | 2 ++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cli-miner.cpp b/cli-miner.cpp index 2f9a635..43329e2 100644 --- a/cli-miner.cpp +++ b/cli-miner.cpp @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) if(strlen(jconf::inst()->GetOutputFile()) != 0) printer::inst()->open_logfile(jconf::inst()->GetOutputFile()); - executor::inst()->ex_start(); + executor::inst()->ex_start(jconf::inst()->DaemonMode()); using namespace std::chrono; uint64_t lastTime = time_point_cast(high_resolution_clock::now()).time_since_epoch().count(); diff --git a/config.txt b/config.txt index 0dcb9e9..98675a2 100644 --- a/config.txt +++ b/config.txt @@ -139,6 +139,14 @@ null, */ "h_print_time" : 60, +/* + * Daemon mode + * + * If you are running the process in the background and you don't need the keyboard reports, set this to true. + * This should solve the hashrate problems on some emulated terminals. + */ +"daemon_mode" : false, + /* * Output file * diff --git a/executor.cpp b/executor.cpp index af10811..383c53e 100644 --- a/executor.cpp +++ b/executor.cpp @@ -43,7 +43,6 @@ executor* executor::oInst = NULL; executor::executor() { - my_thd = nullptr; } void executor::push_timed_event(ex_event&& ev, size_t sec) diff --git a/executor.h b/executor.h index d900b41..74efec0 100644 --- a/executor.h +++ b/executor.h @@ -19,8 +19,7 @@ public: return oInst; }; - void ex_start() { my_thd = new std::thread(&executor::ex_main, this); } - void ex_main(); + void ex_start(bool daemon) { daemon ? ex_main() : std::thread(&executor::ex_main, this).detach(); } void get_http_report(ex_event_name ev_id, std::string& data); @@ -53,7 +52,6 @@ private: telemetry* telem; std::vector* pvThreads; - std::thread* my_thd; size_t current_pool_id; @@ -67,6 +65,8 @@ private: executor(); static executor* oInst; + void ex_main(); + void ex_clock_thd(); void pool_connect(jpsock* pool); diff --git a/jconf.cpp b/jconf.cpp index d272325..3457ed9 100644 --- a/jconf.cpp +++ b/jconf.cpp @@ -48,7 +48,7 @@ using namespace rapidjson; enum configEnum { aCpuThreadsConf, sUseSlowMem, bNiceHashMode, bTlsMode, bTlsSecureAlgo, sTlsFingerprint, sPoolAddr, sWalletAddr, sPoolPwd, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime, - sOutputFile, iHttpdPort, bPreferIpv4 }; + bDaemonMode, sOutputFile, iHttpdPort, bPreferIpv4 }; struct configVal { configEnum iName; @@ -73,6 +73,7 @@ configVal oConfigValues[] = { { iGiveUpLimit, "giveup_limit", kNumberType }, { iVerboseLevel, "verbose_level", kNumberType }, { iAutohashTime, "h_print_time", kNumberType }, + { bDaemonMode, "daemon_mode", kTrueType }, { sOutputFile, "output_file", kStringType }, { iHttpdPort, "httpd_port", kNumberType }, { bPreferIpv4, "prefer_ipv4", kTrueType } @@ -251,6 +252,11 @@ bool jconf::NiceHashMode() return prv->configValues[bNiceHashMode]->GetBool(); } +bool jconf::DaemonMode() +{ + return prv->configValues[bDaemonMode]->GetBool(); +} + const char* jconf::GetOutputFile() { return prv->configValues[sOutputFile]->GetString(); diff --git a/jconf.h b/jconf.h index f932728..c42fbe0 100644 --- a/jconf.h +++ b/jconf.h @@ -54,6 +54,8 @@ public: bool NiceHashMode(); + bool DaemonMode(); + bool PreferIpv4(); inline bool HaveHardwareAes() { return bHaveAes; }