Skip to content

Commit

Permalink
daemon mode feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fireice-uk committed May 26, 2017
1 parent 07ea73d commit 83762e5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli-miner.cpp
Expand Up @@ -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<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
Expand Down
8 changes: 8 additions & 0 deletions config.txt
Expand Up @@ -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
*
Expand Down
1 change: 0 additions & 1 deletion executor.cpp
Expand Up @@ -43,7 +43,6 @@ executor* executor::oInst = NULL;

executor::executor()
{
my_thd = nullptr;
}

void executor::push_timed_event(ex_event&& ev, size_t sec)
Expand Down
6 changes: 3 additions & 3 deletions executor.h
Expand Up @@ -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);

Expand Down Expand Up @@ -53,7 +52,6 @@ class executor

telemetry* telem;
std::vector<minethd*>* pvThreads;
std::thread* my_thd;

size_t current_pool_id;

Expand All @@ -67,6 +65,8 @@ class executor
executor();
static executor* oInst;

void ex_main();

void ex_clock_thd();
void pool_connect(jpsock* pool);

Expand Down
8 changes: 7 additions & 1 deletion jconf.cpp
Expand Up @@ -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;
Expand All @@ -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 }
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions jconf.h
Expand Up @@ -54,6 +54,8 @@ class jconf

bool NiceHashMode();

bool DaemonMode();

bool PreferIpv4();

inline bool HaveHardwareAes() { return bHaveAes; }
Expand Down

0 comments on commit 83762e5

Please sign in to comment.