diff --git a/cli-miner.cpp b/cli-miner.cpp index 2f9a6356..43329e29 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 0dcb9e92..98675a25 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 af108111..383c53e2 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 d900b418..74efec0a 100644 --- a/executor.h +++ b/executor.h @@ -19,8 +19,7 @@ class executor 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 @@ class executor telemetry* telem; std::vector* pvThreads; - std::thread* my_thd; size_t current_pool_id; @@ -67,6 +65,8 @@ class executor 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 d272325c..3457ed9a 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 f932728f..c42fbe03 100644 --- a/jconf.h +++ b/jconf.h @@ -54,6 +54,8 @@ class jconf bool NiceHashMode(); + bool DaemonMode(); + bool PreferIpv4(); inline bool HaveHardwareAes() { return bHaveAes; }