From 4efc1e39f4302b827772186c27803391101aa21b Mon Sep 17 00:00:00 2001 From: avujic Date: Fri, 23 Mar 2018 19:04:40 +0100 Subject: [PATCH] #2018-009, Minor adjustments, code comments --- src/App.cpp | 35 +++++++++++++++++++++++++++++++++-- src/App.h | 10 +++++----- src/Options.cpp | 23 +++++++++++++++-------- src/config.json | 8 ++++---- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index a0d9a0a5..45e442ee 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -53,7 +53,12 @@ App *App::m_self = nullptr; - +/*--------------------------------------------------------------------- +* NAME : App::~App +* SYNOPSIS : App constructor +* DESCRIPTION: +* +---------------------------------------------------------------------*/ App::App(int argc, char **argv) : m_console(nullptr), m_httpd(nullptr), @@ -94,6 +99,13 @@ App::App(int argc, char **argv) : } + +/*--------------------------------------------------------------------- +* NAME : App::~App +* SYNOPSIS : App destructor +* DESCRIPTION: +* +---------------------------------------------------------------------*/ App::~App() { uv_tty_reset_mode(); @@ -106,6 +118,12 @@ App::~App() } +/*--------------------------------------------------------------------- +* NAME : App::exec() +* SYNOPSIS : +* DESCRIPTION: +* +---------------------------------------------------------------------*/ int App::exec() { if (!m_options) { @@ -147,7 +165,12 @@ int App::exec() return r; } - +/*--------------------------------------------------------------------- +* NAME : onConsoleCommand(char command) +* SYNOPSIS : Process commands from console +* DESCRIPTION: +* +---------------------------------------------------------------------*/ void App::onConsoleCommand(char command) { switch (command) { @@ -181,6 +204,12 @@ void App::onConsoleCommand(char command) } +/*--------------------------------------------------------------------- +* NAME : close() +* SYNOPSIS : CTRL+C is pressed, exit application +* DESCRIPTION: +* +---------------------------------------------------------------------*/ void App::close() { m_network->stop(); @@ -213,3 +242,5 @@ void App::onSignal(uv_signal_t *handle, int signum) uv_signal_stop(handle); m_self->close(); } + +/*-----------------end of file------------------------------------------------*/ diff --git a/src/App.h b/src/App.h index 6cc487f9..baa82d96 100644 --- a/src/App.h +++ b/src/App.h @@ -55,11 +55,11 @@ private: static App *m_self; - Console *m_console; - Httpd *m_httpd; - Network *m_network; - Options *m_options; - uv_signal_t m_signal; + Console *m_console; + Httpd *m_httpd; + Network *m_network; + Options *m_options; + uv_signal_t m_signal; }; diff --git a/src/Options.cpp b/src/Options.cpp index 0e58b28d..c8fe460e 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -26,11 +26,7 @@ #include -#ifdef _MSC_VER -# include "getopt/getopt.h" -#else -# include -#endif +include #include "Cpu.h" @@ -276,7 +272,12 @@ Options::~Options() { } - +/*--------------------------------------------------------------------- +* NAME : Options::getJSON(const char *fileName, rapidjson::Document &doc) +* SYNOPSIS : Open config.json file from working folder +* DESCRIPTION: +* +---------------------------------------------------------------------*/ bool Options::getJSON(const char *fileName, rapidjson::Document &doc) { uv_fs_t req; @@ -298,14 +299,20 @@ bool Options::getJSON(const char *fileName, rapidjson::Document &doc) uv_fs_req_cleanup(&req); if (doc.HasParseError()) { - printf("%s:%d: %s\n", fileName, (int) doc.GetErrorOffset(), rapidjson::GetParseError_En(doc.GetParseError())); + std::cout << fileName << " " << (int) doc.GetErrorOffset() \ + << " " << rapidjson::GetParseError_En(doc.GetParseError()) << '\n"'; return false; } return doc.IsObject(); } - +/*--------------------------------------------------------------------- +* NAME : Options::parseArg(int key, const char *arg) +* SYNOPSIS : Arguments parsing +* DESCRIPTION: +* +---------------------------------------------------------------------*/ bool Options::parseArg(int key, const char *arg) { switch (key) { diff --git a/src/config.json b/src/config.json index a332b70c..998e1a1d 100644 --- a/src/config.json +++ b/src/config.json @@ -6,11 +6,11 @@ "cpu-affinity": null, // set process affinity to CPU core(s) // mask 3 for cores 0 and 1 // mask 14 for cores 1,2,3 - "cpu-priority": 3, // set process priority (0 idle, 2 normal to 5 highest) - "donate-level": 3, // donate level, mininum 1% + "cpu-priority": 4, // set process priority (0 idle, 2 normal to 5 highest) + "donate-level": 2, // donate level, mininum 1% "log-file" : "/var/log/xmr_arch64_monero.log", // log all output to a file - "max-cpu-usage": 50, // maximum CPU usage for automatic mode, usually limiting factor is CPU cache not this option. - "print-time": 60, // print hashrate report every N seconds + "max-cpu-usage": 88, // maximum CPU usage for automatic mode, usually limiting factor is CPU cache not this option. + "print-time": 90, // print hashrate report every N seconds "retries": 5, // number of times to retry before switch to backup server "retry-pause": 5, // time to pause between retries "safe": false, // true to safe adjust threads and av settings for current CPU