2018-03-31 06:48:06 +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>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-09-24 11:19:26 +00:00
|
|
|
#ifndef XMRIG_CONFIG_H
|
|
|
|
#define XMRIG_CONFIG_H
|
2018-03-31 06:48:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
2018-04-12 23:38:18 +00:00
|
|
|
#include "common/config/CommonConfig.h"
|
2018-04-13 00:00:51 +00:00
|
|
|
#include "common/xmrig.h"
|
2018-04-01 15:49:21 +00:00
|
|
|
#include "rapidjson/fwd.h"
|
2018-04-13 10:59:27 +00:00
|
|
|
#include "workers/CpuThread.h"
|
2018-03-31 06:48:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace xmrig {
|
|
|
|
|
|
|
|
|
|
|
|
class ConfigLoader;
|
2018-04-01 15:49:21 +00:00
|
|
|
class IThread;
|
2019-02-14 21:59:20 +00:00
|
|
|
class IConfigListener;
|
2019-02-14 22:42:46 +00:00
|
|
|
class Process;
|
2018-03-31 06:48:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The Config class
|
|
|
|
*
|
|
|
|
* Options with dynamic reload:
|
|
|
|
* colors
|
|
|
|
* debug
|
|
|
|
* verbose
|
|
|
|
* custom-diff (only for new connections)
|
|
|
|
* api/worker-id
|
|
|
|
* pools/
|
|
|
|
*/
|
|
|
|
class Config : public CommonConfig
|
|
|
|
{
|
|
|
|
public:
|
2018-04-15 14:41:03 +00:00
|
|
|
enum ThreadsMode {
|
|
|
|
Automatic,
|
|
|
|
Simple,
|
|
|
|
Advanced
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-31 06:48:06 +00:00
|
|
|
Config();
|
|
|
|
|
|
|
|
bool reload(const char *json);
|
|
|
|
|
|
|
|
void getJSON(rapidjson::Document &doc) const override;
|
|
|
|
|
2018-04-13 10:59:27 +00:00
|
|
|
inline AesMode aesMode() const { return m_aesMode; }
|
2018-04-01 15:49:21 +00:00
|
|
|
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
2018-09-24 11:19:26 +00:00
|
|
|
inline Assembly assembly() const { return m_assembly; }
|
2018-04-01 15:49:21 +00:00
|
|
|
inline bool isHugePages() const { return m_hugePages; }
|
2018-09-27 16:07:04 +00:00
|
|
|
inline bool isShouldSave() const { return m_shouldSave && isAutoSave(); }
|
2018-04-13 10:59:27 +00:00
|
|
|
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
|
2018-04-01 15:49:21 +00:00
|
|
|
inline int priority() const { return m_priority; }
|
2018-04-14 00:01:12 +00:00
|
|
|
inline int threadsCount() const { return m_threads.list.size(); }
|
2018-04-13 10:59:27 +00:00
|
|
|
inline int64_t affinity() const { return m_threads.mask; }
|
2018-04-15 14:41:03 +00:00
|
|
|
inline ThreadsMode threadsMode() const { return m_threads.mode; }
|
2018-03-31 06:48:06 +00:00
|
|
|
|
2019-02-14 22:42:46 +00:00
|
|
|
static Config *load(Process *process, IConfigListener *listener);
|
2018-03-31 06:48:06 +00:00
|
|
|
|
|
|
|
protected:
|
2018-04-25 16:17:27 +00:00
|
|
|
bool finalize() override;
|
2018-03-31 06:48:06 +00:00
|
|
|
bool parseBoolean(int key, bool enable) override;
|
|
|
|
bool parseString(int key, const char *arg) override;
|
|
|
|
bool parseUint64(int key, uint64_t arg) override;
|
|
|
|
void parseJSON(const rapidjson::Document &doc) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool parseInt(int key, int arg);
|
|
|
|
|
2018-04-01 15:49:21 +00:00
|
|
|
AlgoVariant getAlgoVariant() const;
|
2018-03-31 06:48:06 +00:00
|
|
|
# ifndef XMRIG_NO_AEON
|
2018-04-01 15:49:21 +00:00
|
|
|
AlgoVariant getAlgoVariantLite() const;
|
2018-03-31 06:48:06 +00:00
|
|
|
# endif
|
|
|
|
|
2018-04-13 10:59:27 +00:00
|
|
|
|
|
|
|
struct Threads
|
|
|
|
{
|
2018-04-15 14:41:03 +00:00
|
|
|
inline Threads() : mask(-1L), count(0), mode(Automatic) {}
|
2018-04-13 10:59:27 +00:00
|
|
|
|
|
|
|
int64_t mask;
|
|
|
|
size_t count;
|
|
|
|
std::vector<CpuThread::Data> cpu;
|
|
|
|
std::vector<IThread *> list;
|
2018-04-15 14:41:03 +00:00
|
|
|
ThreadsMode mode;
|
2018-04-13 10:59:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
AesMode m_aesMode;
|
2018-04-01 15:49:21 +00:00
|
|
|
AlgoVariant m_algoVariant;
|
2018-09-24 11:19:26 +00:00
|
|
|
Assembly m_assembly;
|
2018-03-31 06:48:06 +00:00
|
|
|
bool m_hugePages;
|
|
|
|
bool m_safe;
|
2018-09-27 16:07:04 +00:00
|
|
|
bool m_shouldSave;
|
2018-03-31 06:48:06 +00:00
|
|
|
int m_maxCpuUsage;
|
|
|
|
int m_priority;
|
2018-04-13 10:59:27 +00:00
|
|
|
Threads m_threads;
|
2018-03-31 06:48:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace xmrig */
|
|
|
|
|
2018-09-24 11:19:26 +00:00
|
|
|
#endif /* XMRIG_CONFIG_H */
|