#2018-009, Minor adjustments, code comments

This commit is contained in:
avujic 2018-03-23 19:04:40 +01:00
parent bcfd6a5670
commit 4efc1e39f4
4 changed files with 57 additions and 19 deletions

View file

@ -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------------------------------------------------*/

View file

@ -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;
};

View file

@ -26,11 +26,7 @@
#include <uv.h>
#ifdef _MSC_VER
# include "getopt/getopt.h"
#else
# include <getopt.h>
#endif
include <getopt.h>
#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) {

View file

@ -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