Skip to content

Commit

Permalink
xmrig#341 Added option --dry-run.
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Jan 20, 2018
1 parent 56ffa7a commit 631fd75
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
26 changes: 20 additions & 6 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ int App::exec()
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
Summary::print();

if (m_options->dryRun()) {
LOG_NOTICE("OK");
release();

return 0;
}

# ifndef XMRIG_NO_API
Api::start();
# endif
Expand All @@ -146,12 +153,7 @@ int App::exec()
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
uv_loop_close(uv_default_loop());

delete m_network;

Options::release();
Mem::release();
Platform::release();

release();
return r;
}

Expand Down Expand Up @@ -200,6 +202,18 @@ void App::close()
}


void App::release()
{
if (m_network) {
delete m_network;
}

Options::release();
Mem::release();
Platform::release();
}


void App::onSignal(uv_signal_t *handle, int signum)
{
switch (signum)
Expand Down
1 change: 1 addition & 0 deletions src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class App : public IConsoleListener
private:
void background();
void close();
void release();

static void onSignal(uv_signal_t *handle, int signum);

Expand Down
14 changes: 11 additions & 3 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";

static struct option const options[] = {
{ "algo", 1, nullptr, 'a' },
{ "api-access-token", 1, nullptr, 4001 },
{ "api-port", 1, nullptr, 4000 },
{ "api-worker-id", 1, nullptr, 4002 },
{ "av", 1, nullptr, 'v' },
{ "background", 0, nullptr, 'B' },
{ "config", 1, nullptr, 'c' },
{ "cpu-affinity", 1, nullptr, 1020 },
{ "cpu-priority", 1, nullptr, 1021 },
{ "donate-level", 1, nullptr, 1003 },
{ "dry-run", 0, nullptr, 5000 },
{ "help", 0, nullptr, 'h' },
{ "keepalive", 0, nullptr ,'k' },
{ "log-file", 1, nullptr, 'l' },
Expand All @@ -126,9 +130,6 @@ static struct option const options[] = {
{ "user-agent", 1, nullptr, 1008 },
{ "userpass", 1, nullptr, 'O' },
{ "version", 0, nullptr, 'V' },
{ "api-port", 1, nullptr, 4000 },
{ "api-access-token", 1, nullptr, 4001 },
{ "api-worker-id", 1, nullptr, 4002 },
{ 0, 0, 0, 0 }
};

Expand All @@ -141,6 +142,7 @@ static struct option const config_options[] = {
{ "cpu-affinity", 1, nullptr, 1020 },
{ "cpu-priority", 1, nullptr, 1021 },
{ "donate-level", 1, nullptr, 1003 },
{ "dry-run", 0, nullptr, 5000 },
{ "huge-pages", 0, nullptr, 1009 },
{ "log-file", 1, nullptr, 'l' },
{ "max-cpu-usage", 1, nullptr, 1004 },
Expand Down Expand Up @@ -205,6 +207,7 @@ Options::Options(int argc, char **argv) :
m_background(false),
m_colors(true),
m_doubleHash(false),
m_dryRun(false),
m_hugePages(true),
m_ready(false),
m_safe(false),
Expand Down Expand Up @@ -384,6 +387,7 @@ bool Options::parseArg(int key, const char *arg)
case 'S': /* --syslog */
case 1005: /* --safe */
case 1006: /* --nicehash */
case 5000: /* --dry-run */
return parseBoolean(key, true);

case 1002: /* --no-color */
Expand Down Expand Up @@ -557,6 +561,10 @@ bool Options::parseBoolean(int key, bool enable)
m_colors = enable;
break;

case 5000: /* --dry-run */
m_dryRun = enable;
break;

default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Options
inline bool background() const { return m_background; }
inline bool colors() const { return m_colors; }
inline bool doubleHash() const { return m_doubleHash; }
inline bool dryRun() const { return m_dryRun; }
inline bool hugePages() const { return m_hugePages; }
inline bool syslog() const { return m_syslog; }
inline const char *apiToken() const { return m_apiToken; }
Expand Down Expand Up @@ -110,6 +111,7 @@ class Options
bool m_background;
bool m_colors;
bool m_doubleHash;
bool m_dryRun;
bool m_hugePages;
bool m_ready;
bool m_safe;
Expand Down

0 comments on commit 631fd75

Please sign in to comment.