* [WIP] More unification in Pools class.

This commit is contained in:
XMRig
2019-02-17 10:51:32 +07:00
parent b5638a1006
commit 3f6131bd95
10 changed files with 118 additions and 66 deletions

View File

@@ -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 */

View File

@@ -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;