* [WIP] More unification in Pools class.
This commit is contained in:
parent
f6699b5929
commit
ee4f6e28f0
10 changed files with 118 additions and 66 deletions
|
@ -71,21 +71,20 @@ xmrig::CommonConfig::CommonConfig() :
|
|||
m_apiRestricted(true),
|
||||
m_autoSave(true),
|
||||
m_background(false),
|
||||
m_colors(true),
|
||||
m_dryRun(false),
|
||||
m_syslog(false),
|
||||
m_watch(true),
|
||||
m_apiPort(0),
|
||||
m_donateLevel(kDefaultDonateLevel),
|
||||
m_printTime(60),
|
||||
m_retries(5),
|
||||
m_retryPause(5),
|
||||
m_state(NoneState)
|
||||
{
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
m_retries = 2;
|
||||
m_retryPause = 1;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CommonConfig::isColors() const
|
||||
{
|
||||
return Log::colors;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,32 +104,7 @@ void xmrig::CommonConfig::printAPI()
|
|||
|
||||
void xmrig::CommonConfig::printPools()
|
||||
{
|
||||
for (size_t i = 0; i < m_pools.data().size(); ++i) {
|
||||
if (!isColors()) {
|
||||
Log::i()->text(" * POOL #%-7zu%s algo=%s, TLS=%d",
|
||||
i + 1,
|
||||
m_pools.data()[i].url(),
|
||||
m_pools.data()[i].algorithm().shortName(),
|
||||
static_cast<int>(m_pools.data()[i].isTLS())
|
||||
);
|
||||
}
|
||||
else {
|
||||
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") "\x1B[1;%dm%s\x1B[0m algo " WHITE_BOLD("%s"),
|
||||
i + 1,
|
||||
m_pools.data()[i].isTLS() ? 32 : 36,
|
||||
m_pools.data()[i].url(),
|
||||
m_pools.data()[i].algorithm().shortName()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef APP_DEBUG
|
||||
LOG_NOTICE("POOLS --------------------------------------------------------------------");
|
||||
for (const Pool &pool : m_activePools) {
|
||||
pool.print();
|
||||
}
|
||||
LOG_NOTICE("--------------------------------------------------------------------------");
|
||||
# endif
|
||||
m_pools.print();
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,7 +235,7 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
|
|||
# endif
|
||||
|
||||
case ColorKey: /* --no-color */
|
||||
m_colors = enable;
|
||||
Log::colors = enable;
|
||||
break;
|
||||
|
||||
case WatchKey: /* watch */
|
||||
|
@ -404,15 +378,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
|||
{
|
||||
switch (key) {
|
||||
case RetriesKey: /* --retries */
|
||||
if (arg > 0 && arg <= 1000) {
|
||||
m_retries = arg;
|
||||
}
|
||||
m_pools.setRetries(arg);
|
||||
break;
|
||||
|
||||
case RetryPauseKey: /* --retry-pause */
|
||||
if (arg > 0 && arg <= 3600) {
|
||||
m_retryPause = arg;
|
||||
}
|
||||
m_pools.setRetryPause(arg);
|
||||
break;
|
||||
|
||||
case KeepAliveKey: /* --keepalive */
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
inline bool isApiRestricted() const { return m_apiRestricted; }
|
||||
inline bool isAutoSave() const { return m_autoSave; }
|
||||
inline bool isBackground() const { return m_background; }
|
||||
inline bool isColors() const { return m_colors; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
inline bool isSyslog() const { return m_syslog; }
|
||||
inline const char *apiId() const { return m_apiId.data(); }
|
||||
|
@ -56,9 +55,8 @@ public:
|
|||
inline int apiPort() const { return m_apiPort; }
|
||||
inline int donateLevel() const { return m_donateLevel; }
|
||||
inline int printTime() const { return m_printTime; }
|
||||
inline int retries() const { return m_retries; }
|
||||
inline int retryPause() const { return m_retryPause; }
|
||||
inline void setColors(bool colors) { m_colors = colors; }
|
||||
inline int retries() const { return m_pools.retries(); }
|
||||
inline int retryPause() const { return m_pools.retryPause(); }
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const Algorithm &algorithm() const override { return m_algorithm; }
|
||||
|
@ -66,6 +64,7 @@ public:
|
|||
|
||||
bool save() override;
|
||||
|
||||
bool isColors() const;
|
||||
void printAPI();
|
||||
void printPools();
|
||||
void printVersions();
|
||||
|
@ -90,15 +89,12 @@ protected:
|
|||
bool m_apiRestricted;
|
||||
bool m_autoSave;
|
||||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_dryRun;
|
||||
bool m_syslog;
|
||||
bool m_watch;
|
||||
int m_apiPort;
|
||||
int m_donateLevel;
|
||||
int m_printTime;
|
||||
int m_retries;
|
||||
int m_retryPause;
|
||||
Pools m_pools;
|
||||
State m_state;
|
||||
String m_apiId;
|
||||
|
|
|
@ -29,14 +29,12 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
class Job;
|
||||
class SubmitResult;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client;
|
||||
class Job;
|
||||
class SubmitResult;
|
||||
|
||||
|
||||
class IClientListener
|
||||
|
|
|
@ -45,7 +45,7 @@ ConsoleLog::ConsoleLog(xmrig::Controller *controller) :
|
|||
m_controller(controller)
|
||||
{
|
||||
if (uv_tty_init(uv_default_loop(), &m_tty, 1, 0) < 0) {
|
||||
controller->config()->setColors(false);
|
||||
Log::colors = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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>
|
||||
* 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
|
||||
|
@ -35,9 +36,10 @@
|
|||
|
||||
|
||||
Log *Log::m_self = nullptr;
|
||||
bool Log::colors = true;
|
||||
|
||||
|
||||
static const char *colors[5] = {
|
||||
static const char *color[5] = {
|
||||
"\x1B[0;31m", /* ERR */
|
||||
"\x1B[0;33m", /* WARNING */
|
||||
"\x1B[1;37m", /* NOTICE */
|
||||
|
@ -96,7 +98,7 @@ const char *Log::colorByLevel(ILogBackend::Level level, bool isColors)
|
|||
return "";
|
||||
}
|
||||
|
||||
return colors[level];
|
||||
return color[level];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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>
|
||||
* 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
|
||||
|
@ -48,6 +49,8 @@ public:
|
|||
static const char *endl(bool isColors = true);
|
||||
static void defaultInit();
|
||||
|
||||
static bool colors;
|
||||
|
||||
private:
|
||||
inline Log() {
|
||||
assert(m_self == nullptr);
|
||||
|
|
|
@ -32,7 +32,10 @@
|
|||
#include "common/net/Client.h"
|
||||
|
||||
|
||||
class xmrig::Client::Tls
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client::Tls
|
||||
{
|
||||
public:
|
||||
Tls(Client *client);
|
||||
|
@ -60,4 +63,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_CLIENT_TLS_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue