xmrig/src/Options.h

134 lines
4.5 KiB
C
Raw Normal View History

2017-06-04 17:52:21 +00:00
/* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
2017-06-04 17:52:21 +00:00
*
* 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 __OPTIONS_H__
#define __OPTIONS_H__
#include <stdint.h>
2017-07-31 13:05:16 +00:00
#include <vector>
2017-06-04 17:52:21 +00:00
#include "rapidjson/fwd.h"
2017-06-04 17:52:21 +00:00
class Url;
2017-07-31 13:05:16 +00:00
struct option;
2017-06-04 17:52:21 +00:00
class Options
{
public:
enum AlgoVariant {
AV0_AUTO,
AV1_AESNI,
AV2_AESNI_DOUBLE,
AV3_SOFT_AES,
AV4_SOFT_AES_DOUBLE,
AV_MAX
};
static inline Options* i() { return m_self; }
static Options *parse(int argc, char **argv);
2017-06-26 18:13:05 +00:00
inline bool background() const { return m_background; }
inline bool colors() const { return m_colors; }
inline bool doubleHash() const { return m_doubleHash; }
2018-01-20 13:43:31 +00:00
inline bool dryRun() const { return m_dryRun; }
2017-08-16 11:21:12 +00:00
inline bool hugePages() const { return m_hugePages; }
2017-06-26 18:13:05 +00:00
inline bool syslog() const { return m_syslog; }
inline const char *apiToken() const { return m_apiToken; }
inline const char *apiWorkerId() const { return m_apiWorkerId; }
2017-06-26 18:13:05 +00:00
inline const char *logFile() const { return m_logFile; }
2017-08-16 10:19:14 +00:00
inline const char *userAgent() const { return m_userAgent; }
2017-06-26 18:13:05 +00:00
inline const std::vector<Url*> &pools() const { return m_pools; }
inline int algo() const { return m_algo; }
inline int algoVariant() const { return m_algoVariant; }
2017-09-02 11:14:10 +00:00
inline int apiPort() const { return m_apiPort; }
2017-06-26 18:13:05 +00:00
inline int donateLevel() const { return m_donateLevel; }
inline int printTime() const { return m_printTime; }
2017-08-15 05:19:55 +00:00
inline int priority() const { return m_priority; }
2017-06-26 18:13:05 +00:00
inline int retries() const { return m_retries; }
inline int retryPause() const { return m_retryPause; }
inline int threads() const { return m_threads; }
inline int64_t affinity() const { return m_affinity; }
inline void setColors(bool colors) { m_colors = colors; }
2017-06-04 17:52:21 +00:00
2017-08-15 00:04:46 +00:00
inline static void release() { delete m_self; }
2017-06-08 06:47:25 +00:00
const char *algoName() const;
2017-06-04 17:52:21 +00:00
private:
Options(int argc, char **argv);
~Options();
inline bool isReady() const { return m_ready; }
2017-06-04 17:52:21 +00:00
static Options *m_self;
bool getJSON(const char *fileName, rapidjson::Document &doc);
2017-07-31 13:05:16 +00:00
bool parseArg(int key, const char *arg);
bool parseArg(int key, uint64_t arg);
bool parseBoolean(int key, bool enable);
2017-06-04 17:52:21 +00:00
Url *parseUrl(const char *arg) const;
void adjust();
2017-07-31 13:05:16 +00:00
void parseConfig(const char *fileName);
void parseJSON(const struct option *option, const rapidjson::Value &object);
2017-06-04 17:52:21 +00:00
void showUsage(int status) const;
void showVersion(void);
bool setAlgo(const char *algo);
2017-06-09 00:37:56 +00:00
int getAlgoVariant() const;
# ifndef XMRIG_NO_AEON
int getAlgoVariantLite() const;
# endif
2017-06-04 17:52:21 +00:00
bool m_background;
bool m_colors;
bool m_doubleHash;
2018-01-20 13:43:31 +00:00
bool m_dryRun;
2017-08-16 11:21:12 +00:00
bool m_hugePages;
2017-06-04 17:52:21 +00:00
bool m_ready;
bool m_safe;
bool m_syslog;
char *m_apiToken;
char *m_apiWorkerId;
char *m_logFile;
2017-08-16 10:19:14 +00:00
char *m_userAgent;
2017-06-04 17:52:21 +00:00
int m_algo;
int m_algoVariant;
int m_apiPort;
2017-06-04 17:52:21 +00:00
int m_donateLevel;
int m_maxCpuUsage;
2017-06-16 08:08:10 +00:00
int m_printTime;
2017-08-15 05:19:55 +00:00
int m_priority;
2017-06-04 17:52:21 +00:00
int m_retries;
int m_retryPause;
int m_threads;
int64_t m_affinity;
2017-06-26 18:13:05 +00:00
std::vector<Url*> m_pools;
2017-06-04 17:52:21 +00:00
};
#endif /* __OPTIONS_H__ */