Use early exit for --help and --version options.
This commit is contained in:
parent
14e7c82512
commit
70d6e0e62c
12 changed files with 282 additions and 151 deletions
|
@ -24,6 +24,7 @@ set(HEADERS
|
||||||
src/base/io/Watcher.h
|
src/base/io/Watcher.h
|
||||||
src/base/kernel/interfaces/IConfigListener.h
|
src/base/kernel/interfaces/IConfigListener.h
|
||||||
src/base/kernel/interfaces/IWatcherListener.h
|
src/base/kernel/interfaces/IWatcherListener.h
|
||||||
|
src/base/kernel/Entry.h
|
||||||
src/base/kernel/Process.h
|
src/base/kernel/Process.h
|
||||||
src/base/tools/Arguments.h
|
src/base/tools/Arguments.h
|
||||||
src/base/tools/Handle.h
|
src/base/tools/Handle.h
|
||||||
|
@ -106,6 +107,7 @@ set(SOURCES
|
||||||
src/App.cpp
|
src/App.cpp
|
||||||
src/base/io/Json.cpp
|
src/base/io/Json.cpp
|
||||||
src/base/io/Watcher.cpp
|
src/base/io/Watcher.cpp
|
||||||
|
src/base/kernel/Entry.cpp
|
||||||
src/base/kernel/Process.cpp
|
src/base/kernel/Process.cpp
|
||||||
src/base/tools/Arguments.cpp
|
src/base/tools/Arguments.cpp
|
||||||
src/base/tools/Handle.cpp
|
src/base/tools/Handle.cpp
|
||||||
|
|
|
@ -89,10 +89,6 @@ xmrig::App::~App()
|
||||||
|
|
||||||
int xmrig::App::exec()
|
int xmrig::App::exec()
|
||||||
{
|
{
|
||||||
if (m_controller->isDone()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_controller->isReady()) {
|
if (!m_controller->isReady()) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
120
src/base/kernel/Entry.cpp
Normal file
120
src/base/kernel/Entry.cpp
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_HTTPD
|
||||||
|
# include <microhttpd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_TLS
|
||||||
|
# include <openssl/opensslv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/kernel/Entry.h"
|
||||||
|
#include "base/kernel/Process.h"
|
||||||
|
#include "core/usage.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int showVersion()
|
||||||
|
{
|
||||||
|
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
|
||||||
|
|
||||||
|
# if defined(__clang__)
|
||||||
|
" with clang " __clang_version__);
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
" with GCC");
|
||||||
|
printf(" %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
" with MSVC");
|
||||||
|
printf(" %d", MSVC_VERSION);
|
||||||
|
# else
|
||||||
|
);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
printf("\n features:"
|
||||||
|
# if defined(__i386__) || defined(_M_IX86)
|
||||||
|
" 32-bit"
|
||||||
|
# elif defined(__x86_64__) || defined(_M_AMD64)
|
||||||
|
" 64-bit"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__AES__) || defined(_MSC_VER)
|
||||||
|
" AES"
|
||||||
|
# endif
|
||||||
|
"\n");
|
||||||
|
|
||||||
|
printf("\nlibuv/%s\n", uv_version_string());
|
||||||
|
|
||||||
|
# ifndef XMRIG_NO_HTTPD
|
||||||
|
printf("microhttpd/%s\n", MHD_get_version());
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||||
|
{
|
||||||
|
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||||
|
printf("OpenSSL/%.*s\n", static_cast<int>(strchr(v, ' ') - v), v);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::Entry::Id xmrig::Entry::get(const Process &process)
|
||||||
|
{
|
||||||
|
const Arguments &args = process.arguments();
|
||||||
|
if (args.hasArg("-h") || args.hasArg("--help")) {
|
||||||
|
return Usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.hasArg("-V") || args.hasArg("--version")) {
|
||||||
|
return Version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int xmrig::Entry::exec(const Process &, Id id)
|
||||||
|
{
|
||||||
|
switch (id) {
|
||||||
|
case Usage:
|
||||||
|
printf(usage);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case Version:
|
||||||
|
return showVersion();
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
52
src/base/kernel/Entry.h
Normal file
52
src/base/kernel/Entry.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_ENTRY_H
|
||||||
|
#define XMRIG_ENTRY_H
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Process;
|
||||||
|
|
||||||
|
|
||||||
|
class Entry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Id {
|
||||||
|
Default,
|
||||||
|
Usage,
|
||||||
|
Version
|
||||||
|
};
|
||||||
|
|
||||||
|
static Id get(const Process &process);
|
||||||
|
static int exec(const Process &process, Id id);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_ENTRY_H */
|
|
@ -53,7 +53,6 @@
|
||||||
#include "rapidjson/error/en.h"
|
#include "rapidjson/error/en.h"
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::ConfigLoader::m_done = false;
|
|
||||||
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
||||||
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
||||||
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
|
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
|
||||||
|
@ -239,24 +238,11 @@ bool xmrig::ConfigLoader::getJSON(const char *fileName, rapidjson::Document &doc
|
||||||
|
|
||||||
bool xmrig::ConfigLoader::parseArg(xmrig::IConfig *config, int key, const char *arg)
|
bool xmrig::ConfigLoader::parseArg(xmrig::IConfig *config, int key, const char *arg)
|
||||||
{
|
{
|
||||||
switch (key) {
|
if (key == xmrig::IConfig::ConfigKey) {
|
||||||
case xmrig::IConfig::VersionKey: /* --version */
|
return loadFromFile(config, arg);
|
||||||
showVersion();
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case xmrig::IConfig::HelpKey: /* --help */
|
|
||||||
showUsage();
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case xmrig::IConfig::ConfigKey: /* --config */
|
|
||||||
loadFromFile(config, arg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return config->parseString(key, arg);;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return config->parseString(key, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,56 +269,3 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
|
||||||
config->parseBoolean(option->val, value.IsTrue());
|
config->parseBoolean(option->val, value.IsTrue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::ConfigLoader::showUsage()
|
|
||||||
{
|
|
||||||
m_done = true;
|
|
||||||
|
|
||||||
printf(usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void xmrig::ConfigLoader::showVersion()
|
|
||||||
{
|
|
||||||
m_done = true;
|
|
||||||
|
|
||||||
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
|
|
||||||
|
|
||||||
# if defined(__clang__)
|
|
||||||
" with clang " __clang_version__);
|
|
||||||
# elif defined(__GNUC__)
|
|
||||||
" with GCC");
|
|
||||||
printf(" %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
|
||||||
# elif defined(_MSC_VER)
|
|
||||||
" with MSVC");
|
|
||||||
printf(" %d", MSVC_VERSION);
|
|
||||||
# else
|
|
||||||
);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
printf("\n features:"
|
|
||||||
# if defined(__i386__) || defined(_M_IX86)
|
|
||||||
" 32-bit"
|
|
||||||
# elif defined(__x86_64__) || defined(_M_AMD64)
|
|
||||||
" 64-bit"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(__AES__) || defined(_MSC_VER)
|
|
||||||
" AES"
|
|
||||||
# endif
|
|
||||||
"\n");
|
|
||||||
|
|
||||||
printf("\nlibuv/%s\n", uv_version_string());
|
|
||||||
|
|
||||||
# ifndef XMRIG_NO_HTTPD
|
|
||||||
printf("microhttpd/%s\n", MHD_get_version());
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
|
||||||
{
|
|
||||||
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
|
||||||
printf("OpenSSL/%.*s\n", static_cast<int>(strchr(v, ' ') - v), v);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -56,16 +56,11 @@ public:
|
||||||
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
||||||
static void release();
|
static void release();
|
||||||
|
|
||||||
static inline bool isDone() { return m_done; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool getJSON(const char *fileName, rapidjson::Document &doc);
|
static bool getJSON(const char *fileName, rapidjson::Document &doc);
|
||||||
static bool parseArg(IConfig *config, int key, const char *arg);
|
static bool parseArg(IConfig *config, int key, const char *arg);
|
||||||
static void parseJSON(IConfig *config, const struct option *option, const rapidjson::Value &object);
|
static void parseJSON(IConfig *config, const struct option *option, const rapidjson::Value &object);
|
||||||
static void showUsage();
|
|
||||||
static void showVersion();
|
|
||||||
|
|
||||||
static bool m_done;
|
|
||||||
static ConfigWatcher *m_watcher;
|
static ConfigWatcher *m_watcher;
|
||||||
static IConfigCreator *m_creator;
|
static IConfigCreator *m_creator;
|
||||||
static IConfigListener *m_listener;
|
static IConfigListener *m_listener;
|
||||||
|
|
|
@ -52,7 +52,6 @@ public:
|
||||||
ColorKey = 1002,
|
ColorKey = 1002,
|
||||||
ConfigKey = 'c',
|
ConfigKey = 'c',
|
||||||
DonateLevelKey = 1003,
|
DonateLevelKey = 1003,
|
||||||
HelpKey = 'h',
|
|
||||||
KeepAliveKey = 'k',
|
KeepAliveKey = 'k',
|
||||||
LogFileKey = 'l',
|
LogFileKey = 'l',
|
||||||
PasswordKey = 'p',
|
PasswordKey = 'p',
|
||||||
|
@ -66,7 +65,6 @@ public:
|
||||||
UserpassKey = 'O',
|
UserpassKey = 'O',
|
||||||
VariantKey = 1010,
|
VariantKey = 1010,
|
||||||
VerboseKey = 1100,
|
VerboseKey = 1100,
|
||||||
VersionKey = 'V',
|
|
||||||
WatchKey = 1105,
|
WatchKey = 1105,
|
||||||
TlsKey = 1013,
|
TlsKey = 1013,
|
||||||
FingerprintKey = 1014,
|
FingerprintKey = 1014,
|
||||||
|
|
|
@ -40,65 +40,7 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
static char const usage[] = "\
|
static char const short_options[] = "a:c:kBp:Px:r:R:s:t:T:o:u:O:v:l:S";
|
||||||
Usage: " APP_ID " [OPTIONS]\n\
|
|
||||||
Options:\n\
|
|
||||||
-a, --algo=ALGO specify the algorithm to use\n\
|
|
||||||
cryptonight\n"
|
|
||||||
#ifndef XMRIG_NO_AEON
|
|
||||||
"\
|
|
||||||
cryptonight-lite\n"
|
|
||||||
#endif
|
|
||||||
#ifndef XMRIG_NO_SUMO
|
|
||||||
"\
|
|
||||||
cryptonight-heavy\n"
|
|
||||||
#endif
|
|
||||||
"\
|
|
||||||
-o, --url=URL URL of mining server\n\
|
|
||||||
-O, --userpass=U:P username:password pair for mining server\n\
|
|
||||||
-u, --user=USERNAME username for mining server\n\
|
|
||||||
-p, --pass=PASSWORD password for mining server\n\
|
|
||||||
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
|
|
||||||
-t, --threads=N number of miner threads\n\
|
|
||||||
-v, --av=N algorithm variation, 0 auto select\n\
|
|
||||||
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)\n\
|
|
||||||
--nicehash enable nicehash.com support\n\
|
|
||||||
--tls enable SSL/TLS support (needs pool support)\n\
|
|
||||||
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning\n\
|
|
||||||
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
|
|
||||||
-R, --retry-pause=N time to pause between retries (default: 5)\n\
|
|
||||||
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
|
|
||||||
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
|
|
||||||
--no-huge-pages disable huge pages support\n\
|
|
||||||
--no-color disable colored output\n\
|
|
||||||
--variant algorithm PoW variant\n\
|
|
||||||
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
|
||||||
--user-agent set custom user-agent string for pool\n\
|
|
||||||
-B, --background run the miner in the background\n\
|
|
||||||
-c, --config=FILE load a JSON-format configuration file\n\
|
|
||||||
-l, --log-file=FILE log all output to a file\n"
|
|
||||||
# ifdef HAVE_SYSLOG_H
|
|
||||||
"\
|
|
||||||
-S, --syslog use system log for output messages\n"
|
|
||||||
# endif
|
|
||||||
"\
|
|
||||||
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
|
|
||||||
--safe safe adjust threads and av settings for current CPU\n\
|
|
||||||
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen, bulldozer.\n\
|
|
||||||
--print-time=N print hashrate report every N seconds\n\
|
|
||||||
--api-port=N port for the miner API\n\
|
|
||||||
--api-access-token=T access token for API\n\
|
|
||||||
--api-worker-id=ID custom worker-id for API\n\
|
|
||||||
--api-id=ID custom instance ID for API\n\
|
|
||||||
--api-ipv6 enable IPv6 support for API\n\
|
|
||||||
--api-no-restricted enable full remote access (only if API token set)\n\
|
|
||||||
--dry-run test configuration and exit\n\
|
|
||||||
-h, --help display this help and exit\n\
|
|
||||||
-V, --version output version information and exit\n\
|
|
||||||
";
|
|
||||||
|
|
||||||
|
|
||||||
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[] = {
|
static struct option const options[] = {
|
||||||
|
@ -116,7 +58,6 @@ static struct option const options[] = {
|
||||||
{ "cpu-priority", 1, nullptr, xmrig::IConfig::CPUPriorityKey },
|
{ "cpu-priority", 1, nullptr, xmrig::IConfig::CPUPriorityKey },
|
||||||
{ "donate-level", 1, nullptr, xmrig::IConfig::DonateLevelKey },
|
{ "donate-level", 1, nullptr, xmrig::IConfig::DonateLevelKey },
|
||||||
{ "dry-run", 0, nullptr, xmrig::IConfig::DryRunKey },
|
{ "dry-run", 0, nullptr, xmrig::IConfig::DryRunKey },
|
||||||
{ "help", 0, nullptr, xmrig::IConfig::HelpKey },
|
|
||||||
{ "keepalive", 0, nullptr, xmrig::IConfig::KeepAliveKey },
|
{ "keepalive", 0, nullptr, xmrig::IConfig::KeepAliveKey },
|
||||||
{ "log-file", 1, nullptr, xmrig::IConfig::LogFileKey },
|
{ "log-file", 1, nullptr, xmrig::IConfig::LogFileKey },
|
||||||
{ "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey },
|
{ "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey },
|
||||||
|
@ -139,7 +80,6 @@ static struct option const options[] = {
|
||||||
{ "rig-id", 1, nullptr, xmrig::IConfig::RigIdKey },
|
{ "rig-id", 1, nullptr, xmrig::IConfig::RigIdKey },
|
||||||
{ "tls", 0, nullptr, xmrig::IConfig::TlsKey },
|
{ "tls", 0, nullptr, xmrig::IConfig::TlsKey },
|
||||||
{ "tls-fingerprint", 1, nullptr, xmrig::IConfig::FingerprintKey },
|
{ "tls-fingerprint", 1, nullptr, xmrig::IConfig::FingerprintKey },
|
||||||
{ "version", 0, nullptr, xmrig::IConfig::VersionKey },
|
|
||||||
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
|
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
|
||||||
{ nullptr, 0, nullptr, 0 }
|
{ nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,12 +81,6 @@ xmrig::Controller::~Controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Controller::isDone() const
|
|
||||||
{
|
|
||||||
return ConfigLoader::isDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Controller::isReady() const
|
bool xmrig::Controller::isReady() const
|
||||||
{
|
{
|
||||||
return d_ptr->config && d_ptr->network;
|
return d_ptr->config && d_ptr->network;
|
||||||
|
|
|
@ -48,7 +48,6 @@ public:
|
||||||
Controller(Process *process);
|
Controller(Process *process);
|
||||||
~Controller() override;
|
~Controller() override;
|
||||||
|
|
||||||
bool isDone() const;
|
|
||||||
bool isReady() const;
|
bool isReady() const;
|
||||||
Config *config() const;
|
Config *config() const;
|
||||||
int init();
|
int init();
|
||||||
|
|
95
src/core/usage.h
Normal file
95
src/core/usage.h
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_USAGE_H
|
||||||
|
#define XMRIG_USAGE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
static char const usage[] = "\
|
||||||
|
Usage: " APP_ID " [OPTIONS]\n\
|
||||||
|
Options:\n\
|
||||||
|
-a, --algo=ALGO specify the algorithm to use\n\
|
||||||
|
cryptonight\n"
|
||||||
|
#ifndef XMRIG_NO_AEON
|
||||||
|
"\
|
||||||
|
cryptonight-lite\n"
|
||||||
|
#endif
|
||||||
|
#ifndef XMRIG_NO_SUMO
|
||||||
|
"\
|
||||||
|
cryptonight-heavy\n"
|
||||||
|
#endif
|
||||||
|
"\
|
||||||
|
-o, --url=URL URL of mining server\n\
|
||||||
|
-O, --userpass=U:P username:password pair for mining server\n\
|
||||||
|
-u, --user=USERNAME username for mining server\n\
|
||||||
|
-p, --pass=PASSWORD password for mining server\n\
|
||||||
|
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
|
||||||
|
-t, --threads=N number of miner threads\n\
|
||||||
|
-v, --av=N algorithm variation, 0 auto select\n\
|
||||||
|
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)\n\
|
||||||
|
--nicehash enable nicehash.com support\n\
|
||||||
|
--tls enable SSL/TLS support (needs pool support)\n\
|
||||||
|
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning\n\
|
||||||
|
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
|
||||||
|
-R, --retry-pause=N time to pause between retries (default: 5)\n\
|
||||||
|
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
|
||||||
|
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
|
||||||
|
--no-huge-pages disable huge pages support\n\
|
||||||
|
--no-color disable colored output\n\
|
||||||
|
--variant algorithm PoW variant\n\
|
||||||
|
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
||||||
|
--user-agent set custom user-agent string for pool\n\
|
||||||
|
-B, --background run the miner in the background\n\
|
||||||
|
-c, --config=FILE load a JSON-format configuration file\n\
|
||||||
|
-l, --log-file=FILE log all output to a file\n"
|
||||||
|
# ifdef HAVE_SYSLOG_H
|
||||||
|
"\
|
||||||
|
-S, --syslog use system log for output messages\n"
|
||||||
|
# endif
|
||||||
|
"\
|
||||||
|
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
|
||||||
|
--safe safe adjust threads and av settings for current CPU\n\
|
||||||
|
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen, bulldozer.\n\
|
||||||
|
--print-time=N print hashrate report every N seconds\n\
|
||||||
|
--api-port=N port for the miner API\n\
|
||||||
|
--api-access-token=T access token for API\n\
|
||||||
|
--api-worker-id=ID custom worker-id for API\n\
|
||||||
|
--api-id=ID custom instance ID for API\n\
|
||||||
|
--api-ipv6 enable IPv6 support for API\n\
|
||||||
|
--api-no-restricted enable full remote access (only if API token set)\n\
|
||||||
|
--dry-run test configuration and exit\n\
|
||||||
|
-h, --help display this help and exit\n\
|
||||||
|
-V, --version output version information and exit\n\
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
#endif /* XMRIG_USAGE_H */
|
|
@ -23,13 +23,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
#include "base/kernel/Entry.h"
|
||||||
#include "base/kernel/Process.h"
|
#include "base/kernel/Process.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
xmrig::Process process(argc, argv);
|
using namespace xmrig;
|
||||||
|
|
||||||
xmrig::App app(&process);
|
Process process(argc, argv);
|
||||||
|
const Entry::Id entry = Entry::get(process);
|
||||||
|
if (entry) {
|
||||||
|
return Entry::exec(process, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
App app(&process);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue