diff --git a/src/api/v1/ApiRouter.cpp b/src/api/v1/ApiRouter.cpp
index 212ef10..8c02b96 100644
--- a/src/api/v1/ApiRouter.cpp
+++ b/src/api/v1/ApiRouter.cpp
@@ -28,6 +28,7 @@
#include "base/tools/Buffer.h"
#include "core/config/Config.h"
#include "core/Controller.h"
+#include "proxy/Counters.h"
#include "proxy/Miner.h"
#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
@@ -186,7 +187,7 @@ void xmrig::ApiRouter::getMinersSummary(rapidjson::Value &reply, rapidjson::Docu
upstreams.AddMember("sleep", stats.upstreams.sleep, allocator);
upstreams.AddMember("error", stats.upstreams.error, allocator);
upstreams.AddMember("total", stats.upstreams.total, allocator);
- upstreams.AddMember("ratio", normalize(stats.upstreams.ratio), allocator);
+ upstreams.AddMember("ratio", normalize(stats.upstreams.ratio(Counters::miners())), allocator);
reply.AddMember("upstreams", upstreams, allocator);
}
diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp
index 9be0640..46bed83 100644
--- a/src/core/config/Config.cpp
+++ b/src/core/config/Config.cpp
@@ -22,23 +22,27 @@
* along with this program. If not, see .
*/
+#include "core/config/Config.h"
+#include "base/io/log/Log.h"
+#include "donate.h"
+#include "rapidjson/document.h"
+#include "base/kernel/interfaces/IJsonReader.h"
+
+
+#include
#include
#include
#include
#include
-#include "base/io/log/Log.h"
-#include "core/config/Config.h"
-#include "donate.h"
-#include "rapidjson/document.h"
-#include "base/kernel/interfaces/IJsonReader.h"
+namespace xmrig {
-static const char *modeNames[] = {
- "nicehash",
- "simple"
-};
+static const std::array modeNames = { "nicehash", "simple" };
+
+
+} // namespace xmrig
#if defined(_WIN32) && !defined(strncasecmp)
@@ -46,9 +50,6 @@ static const char *modeNames[] = {
#endif
-xmrig::Config::Config() = default;
-
-
bool xmrig::Config::isTLS() const
{
# ifdef XMRIG_FEATURE_TLS
@@ -196,11 +197,9 @@ void xmrig::Config::setMode(const char *mode)
return;
}
- constexpr const size_t size = sizeof(modeNames) / sizeof((modeNames)[0]);
-
- for (size_t i = 0; i < size; i++) {
+ for (size_t i = 0; i < modeNames.size(); i++) {
if (modeNames[i] && !strcmp(mode, modeNames[i])) {
- m_mode = static_cast(i);
+ m_mode = static_cast(i);
break;
}
}
diff --git a/src/core/config/Config.h b/src/core/config/Config.h
index ca72b3e..240d382 100644
--- a/src/core/config/Config.h
+++ b/src/core/config/Config.h
@@ -26,10 +26,6 @@
#define XMRIG_CONFIG_H
-#include
-#include
-
-
#include "base/kernel/config/BaseConfig.h"
#include "base/tools/String.h"
#include "proxy/BindHost.h"
@@ -42,6 +38,10 @@
#endif
+#include
+#include
+
+
namespace xmrig {
@@ -50,17 +50,6 @@ class IConfigListener;
class Process;
-/**
- * @brief The Config class
- *
- * Options with dynamic reload:
- * colors
- * debug
- * verbose
- * custom-diff (only for new connections)
- * api/worker-id
- * pools/
- */
class Config : public BaseConfig
{
public:
@@ -69,7 +58,7 @@ public:
SIMPLE_MODE
};
- Config();
+ Config() = default;
bool isTLS() const;
const char *modeName() const;
diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp
index 48bfc19..b1ed552 100644
--- a/src/core/config/ConfigTransform.cpp
+++ b/src/core/config/ConfigTransform.cpp
@@ -37,9 +37,6 @@ static const char *kTls = "tls";
}
-xmrig::ConfigTransform::ConfigTransform() = default;
-
-
void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const char *arg)
{
BaseTransform::transform(doc, key, arg);
@@ -81,6 +78,9 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
case IConfig::ReuseTimeoutKey: /* --reuse-timeout */
return transformUint64(doc, key, static_cast(strtol(arg, nullptr, 10)));
+ case IConfig::LoginFileKey: /* --login-file */
+ return set(doc, "login-file", arg);
+
# ifdef XMRIG_FEATURE_TLS
case IConfig::TlsCertKey: /* --tls-cert */
return set(doc, kTls, "cert", arg);
diff --git a/src/core/config/ConfigTransform.h b/src/core/config/ConfigTransform.h
index 2d291d8..4fc15ca 100644
--- a/src/core/config/ConfigTransform.h
+++ b/src/core/config/ConfigTransform.h
@@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466
* Copyright 2016 Jay D Dee
* Copyright 2017-2018 XMR-Stak ,
- * Copyright 2016-2018 XMRig ,
+ * Copyright 2018-2019 SChernykh
+ * Copyright 2016-2019 XMRig ,
*
* 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
@@ -34,7 +35,7 @@ namespace xmrig {
class ConfigTransform : public BaseTransform
{
public:
- ConfigTransform();
+ ConfigTransform() = default;
protected:
void transform(rapidjson::Document &doc, int key, const char *arg) override;
diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h
index 2c382ed..1621376 100644
--- a/src/core/config/Config_platform.h
+++ b/src/core/config/Config_platform.h
@@ -40,7 +40,7 @@
namespace xmrig {
-static char const short_options[] = "c:khBp:Px:r:R:s:T:o:u:O:Vl:Sb:A:a:C:m:";
+static char const short_options[] = "c:khBp:Px:r:R:s:T:o:u:O:Vl:Sb:A:a:C:m:L:";
static struct option const options[] = {
@@ -90,6 +90,7 @@ static struct option const options[] = {
{ "tls-ciphersuites", 1, nullptr, IConfig::TlsCipherSuitesKey},
{ "no-algo-ext", 0, nullptr, IConfig::AlgoExtKey },
{ "access-password", 1, nullptr, IConfig::ProxyPasswordKey },
+ { "login-file", 1, nullptr, IConfig::LoginFileKey },
{ nullptr, 0, nullptr, 0 }
};
diff --git a/src/proxy/Error.cpp b/src/proxy/Error.cpp
index 1e2dfad..91710ed 100644
--- a/src/proxy/Error.cpp
+++ b/src/proxy/Error.cpp
@@ -38,11 +38,12 @@ static const char *kUnknownError = "Unknown error";
static const char *kIncompatibleAlgorithm = "No compatible algorithm found, change algo option in your miner.";
static const char *kIncorrectAlgorithm = "Incorrect algorithm";
static const char *kForbidden = "Permission denied";
+static const char *kRouteNotFound = "Algorithm negotiation failed";
} /* namespace xmrig */
-const char *xmrig::Error::toString(Code code)
+const char *xmrig::Error::toString(int code)
{
switch (code)
{
@@ -73,6 +74,9 @@ const char *xmrig::Error::toString(Code code)
case Forbidden:
return kForbidden;
+ case RouteNotFound:
+ return kRouteNotFound;
+
default:
break;
}
diff --git a/src/proxy/Error.h b/src/proxy/Error.h
index 9f25812..83a2355 100644
--- a/src/proxy/Error.h
+++ b/src/proxy/Error.h
@@ -42,10 +42,11 @@ public:
Unauthenticated,
IncompatibleAlgorithm,
IncorrectAlgorithm,
- Forbidden
+ Forbidden,
+ RouteNotFound
};
- static const char *toString(Code code);
+ static const char *toString(int code);
};
diff --git a/src/proxy/Miner.cpp b/src/proxy/Miner.cpp
index 72abba1..cc8e290 100644
--- a/src/proxy/Miner.cpp
+++ b/src/proxy/Miner.cpp
@@ -22,15 +22,10 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include
-
-
+#include "proxy/Miner.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/net/stratum/Job.h"
-#include "base/net/stratum/SubmitResult.h"
#include "base/tools/Buffer.h"
#include "base/tools/Chrono.h"
#include "base/tools/Handle.h"
@@ -38,11 +33,10 @@
#include "proxy/Counters.h"
#include "proxy/Error.h"
#include "proxy/Events.h"
+#include "proxy/events/AcceptEvent.h"
#include "proxy/events/CloseEvent.h"
#include "proxy/events/LoginEvent.h"
-#include "proxy/events/AcceptEvent.h"
#include "proxy/events/SubmitEvent.h"
-#include "proxy/Miner.h"
#include "proxy/tls/TlsContext.h"
#include "proxy/Uuid.h"
#include "rapidjson/document.h"
@@ -56,6 +50,11 @@
#endif
+#include
+#include
+#include
+
+
namespace xmrig {
static int64_t nextId = 0;
char Miner::m_sendBuf[2048] = { 0 };
@@ -64,21 +63,10 @@ namespace xmrig {
xmrig::Miner::Miner(const TlsContext *ctx, uint16_t port) :
- m_routeId(-1),
m_id(++nextId),
- m_loginId(0),
- m_recvBufPos(0),
- m_mapperId(-1),
- m_state(WaitLoginState),
- m_tls(nullptr),
m_localPort(port),
- m_customDiff(0),
- m_diff(0),
- m_expire(Chrono::steadyMSecs() + kLoginTimeout),
- m_rx(0),
- m_timestamp(Chrono::currentMSecsSinceEpoch()),
- m_tx(0),
- m_fixedByte(0)
+ m_expire(Chrono::currentMSecsSinceEpoch() + kLoginTimeout),
+ m_timestamp(Chrono::currentMSecsSinceEpoch())
{
m_key = m_storage.add(this);
@@ -215,8 +203,15 @@ bool xmrig::Miner::parseRequest(int64_t id, const char *method, const rapidjson:
const rapidjson::Value &value = params["algo"];
if (value.IsArray()) {
- for (const rapidjson::Value &algo : value.GetArray()) {
- algorithms.push_back(algo.GetString());
+ algorithms.reserve(value.Size());
+
+ for (const auto &i : value.GetArray()) {
+ Algorithm algo(i.GetString());
+ if (!algo.isValid()) {
+ continue;
+ }
+
+ algorithms.emplace_back(algo);
}
}
}
@@ -320,7 +315,7 @@ bool xmrig::Miner::send(BIO *bio)
void xmrig::Miner::heartbeat()
{
- m_expire = Chrono::steadyMSecs() + kSocketTimeout;
+ m_expire = Chrono::currentMSecsSinceEpoch() + kSocketTimeout;
}
@@ -572,7 +567,7 @@ void xmrig::Miner::shutdown(bool)
}
-void xmrig::Miner::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
+void xmrig::Miner::onAllocBuffer(uv_handle_t *handle, size_t, uv_buf_t *buf)
{
auto miner = getMiner(handle->data);
if (!miner) {
@@ -584,7 +579,7 @@ void xmrig::Miner::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_
}
-void xmrig::Miner::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
+void xmrig::Miner::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *)
{
Miner *miner = getMiner(stream->data);
if (!miner) {
diff --git a/src/proxy/Miner.h b/src/proxy/Miner.h
index 736960d..3bdb25f 100644
--- a/src/proxy/Miner.h
+++ b/src/proxy/Miner.h
@@ -32,11 +32,12 @@
#include "base/net/tools/Storage.h"
+#include "base/tools/Object.h"
#include "base/tools/String.h"
#include "rapidjson/fwd.h"
-typedef struct bio_st BIO;
+using BIO = struct bio_st;
namespace xmrig {
@@ -49,6 +50,8 @@ class TlsContext;
class Miner
{
public:
+ XMRIG_DISABLE_COPY_MOVE_DEFAULT(Miner)
+
enum State {
WaitLoginState,
WaitReadyState,
@@ -126,26 +129,26 @@ private:
char m_buf[4096]{};
char m_ip[46]{};
char m_rpcId[37]{};
- int32_t m_routeId;
+ int32_t m_routeId = -1;
int64_t m_id;
- int64_t m_loginId;
- size_t m_recvBufPos;
- ssize_t m_mapperId;
- State m_state;
+ int64_t m_loginId = 0;
+ size_t m_recvBufPos = 0;
+ ssize_t m_mapperId = -1;
+ State m_state = WaitLoginState;
std::bitset m_extensions;
String m_agent;
String m_password;
String m_rigId;
String m_user;
- Tls *m_tls;
+ Tls *m_tls = nullptr;
uint16_t m_localPort;
- uint64_t m_customDiff;
- uint64_t m_diff;
+ uint64_t m_customDiff = 0;
+ uint64_t m_diff = 0;
uint64_t m_expire;
- uint64_t m_rx;
+ uint64_t m_rx = 0;
uint64_t m_timestamp;
- uint64_t m_tx;
- uint8_t m_fixedByte;
+ uint64_t m_tx = 0;
+ uint8_t m_fixedByte = 0;
uintptr_t m_key;
uv_buf_t m_recvBuf{};
uv_tcp_t *m_socket;
diff --git a/src/proxy/StatsData.h b/src/proxy/StatsData.h
index acd121d..7b8730a 100644
--- a/src/proxy/StatsData.h
+++ b/src/proxy/StatsData.h
@@ -41,10 +41,7 @@ namespace xmrig {
class StatsData
{
public:
- inline StatsData()
- {
- startTime = Chrono::currentMSecsSinceEpoch();
- }
+ inline StatsData() : startTime(Chrono::currentMSecsSinceEpoch()) {}
inline uint32_t avgTime() const
@@ -71,9 +68,26 @@ public:
}
- inline uint64_t uptime() const
+ inline double ratio() const { return upstreams.ratio(miners); }
+ inline uint64_t uptime() const { return (Chrono::currentMSecsSinceEpoch() - startTime) / 1000; }
+
+
+ inline StatsData &operator+=(const StatsData &other)
{
- return (Chrono::currentMSecsSinceEpoch() - startTime) / 1000;
+ upstreams += other.upstreams;
+ accepted += other.accepted;
+ connections += other.connections;
+ donateHashes += other.donateHashes;
+ expired += other.expired;
+ hashes += other.hashes;
+ invalid += other.invalid;
+ rejected += other.rejected;
+
+ for (size_t i = 0; i < 6; ++i) {
+ hashrate[i] += other.hashrate[i];
+ }
+
+ return *this;
}
diff --git a/src/proxy/TickingCounter.h b/src/proxy/TickingCounter.h
index caa1436..c37f5f2 100644
--- a/src/proxy/TickingCounter.h
+++ b/src/proxy/TickingCounter.h
@@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones
* Copyright 2014-2016 Wolf9466
* Copyright 2016 Jay D Dee
- * Copyright 2016-2017 XMRig
- *
+ * Copyright 2017-2018 XMR-Stak ,
+ * Copyright 2018-2019 SChernykh
+ * Copyright 2016-2019 XMRig ,
*
* 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
@@ -21,22 +22,19 @@
* along with this program. If not, see .
*/
-#ifndef __TICKINGCOUNTER_H__
-#define __TICKINGCOUNTER_H__
+#ifndef XMRIG_TICKINGCOUNTER_H
+#define XMRIG_TICKINGCOUNTER_H
-#include
-#include
+#include
+#include
#include
template class TickingCounter
{
public:
- inline TickingCounter(size_t tickTime) :
- m_tickTime(tickTime),
- m_pending(0)
- {}
+ inline TickingCounter(size_t tickTime) : m_tickTime(tickTime) {}
inline double calc(size_t seconds) const
@@ -64,8 +62,8 @@ public:
private:
size_t m_tickTime;
std::vector m_data;
- T m_pending;
+ T m_pending = 0;
};
-#endif /* __TICKINGCOUNTER_H__ */
+#endif /* XMRIG_TICKINGCOUNTER_H */
diff --git a/src/proxy/events/Event.h b/src/proxy/events/Event.h
index 1d89ad8..7949dac 100644
--- a/src/proxy/events/Event.h
+++ b/src/proxy/events/Event.h
@@ -38,10 +38,7 @@ namespace xmrig {
class Event : public IEvent
{
public:
- inline Event(Type type) :
- m_rejected(false),
- m_type(type)
- {}
+ inline Event(Type type) : m_type(type) {}
static bool exec(IEvent *event);
@@ -52,8 +49,8 @@ public:
inline bool start() { return exec(this); }
protected:
- bool m_rejected;
- Type m_type;
+ bool m_rejected = false;
+ const Type m_type;
static char m_buf[4096];
};
diff --git a/src/proxy/events/LoginEvent.h b/src/proxy/events/LoginEvent.h
index 31c286d..0ab5b8a 100644
--- a/src/proxy/events/LoginEvent.h
+++ b/src/proxy/events/LoginEvent.h
@@ -26,9 +26,10 @@
#define XMRIG_LOGINEVENT_H
-#include
+#include
+#include "base/tools/String.h"
#include "crypto/common/Algorithm.h"
#include "proxy/events/MinerEvent.h"
#include "rapidjson/fwd.h"
@@ -49,6 +50,8 @@ public:
const Algorithms &algorithms;
const int64_t loginId;
const rapidjson::Value ¶ms;
+ int error = -1;
+ String flow;
protected:
diff --git a/src/proxy/events/MinerEvent.cpp b/src/proxy/events/MinerEvent.cpp
index b4f1c8c..309f783 100644
--- a/src/proxy/events/MinerEvent.cpp
+++ b/src/proxy/events/MinerEvent.cpp
@@ -34,3 +34,9 @@ const char *xmrig::MinerEvent::ip() const
{
return m_miner ? m_miner->ip() : kDefaultIP;
}
+
+
+int32_t xmrig::MinerEvent::route() const
+{
+ return m_miner ? m_miner->routeId() : -1;
+}
diff --git a/src/proxy/events/MinerEvent.h b/src/proxy/events/MinerEvent.h
index 69dd696..62e6e18 100644
--- a/src/proxy/events/MinerEvent.h
+++ b/src/proxy/events/MinerEvent.h
@@ -45,10 +45,9 @@ public:
protected:
- inline MinerEvent(Type type, Miner *miner) :
- Event(type),
- m_miner(miner)
- {}
+ inline MinerEvent(Type type, Miner *miner) : Event(type), m_miner(miner) {}
+
+ int32_t route() const override;
private:
diff --git a/src/proxy/events/SubmitEvent.h b/src/proxy/events/SubmitEvent.h
index bdc0aff..aecce78 100644
--- a/src/proxy/events/SubmitEvent.h
+++ b/src/proxy/events/SubmitEvent.h
@@ -44,6 +44,7 @@ public:
}
+ bool expired = false;
JobResult request;
diff --git a/src/proxy/interfaces/IEvent.h b/src/proxy/interfaces/IEvent.h
index ec2a179..664ce5d 100644
--- a/src/proxy/interfaces/IEvent.h
+++ b/src/proxy/interfaces/IEvent.h
@@ -26,6 +26,9 @@
#define XMRIG_IEVENT_H
+#include
+
+
namespace xmrig {
@@ -43,6 +46,7 @@ public:
virtual ~IEvent() = default;
virtual bool isRejected() const = 0;
+ virtual int32_t route() const = 0;
virtual Type type() const = 0;
virtual void reject() = 0;
};
diff --git a/src/proxy/interfaces/ISplitter.h b/src/proxy/interfaces/ISplitter.h
index 547aa02..eae48ce 100644
--- a/src/proxy/interfaces/ISplitter.h
+++ b/src/proxy/interfaces/ISplitter.h
@@ -26,7 +26,7 @@
#define XMRIG_ISPLITTER_H
-#include
+#include
namespace xmrig {
@@ -35,23 +35,35 @@ namespace xmrig {
class Upstreams
{
public:
- inline Upstreams() : active(0), sleep(0), total(0), error(0), ratio(0.0) {}
+ Upstreams() = default;
- inline Upstreams(uint64_t active, uint64_t sleep, uint64_t total, uint64_t miners) :
+ inline Upstreams(uint64_t active, uint64_t sleep, uint64_t total) :
active(active),
sleep(sleep),
total(total),
- error(total - active - sleep),
- ratio(active > 0 ? (static_cast(miners) / active) : 0.0)
+ error(total - active - sleep)
{}
- uint64_t active;
- uint64_t sleep;
- uint64_t total;
- uint64_t error;
- double ratio;
+ inline double ratio(uint64_t miners) const { return active > 0 ? (static_cast(miners) / active) : 0.0; }
+
+
+ inline Upstreams &operator+=(const Upstreams &other)
+ {
+ active += other.active;
+ sleep += other.sleep;
+ total += other.total;
+ error += other.error;
+
+ return *this;
+ }
+
+
+ uint64_t active = 0;
+ uint64_t sleep = 0;
+ uint64_t total = 0;
+ uint64_t error = 0;
};
diff --git a/src/proxy/log/AccessLog.cpp b/src/proxy/log/AccessLog.cpp
index 520988d..22eacd4 100644
--- a/src/proxy/log/AccessLog.cpp
+++ b/src/proxy/log/AccessLog.cpp
@@ -23,23 +23,23 @@
*/
-#include
-#include
-#include
-#include
-
-
+#include "proxy/log/AccessLog.h"
#include "base/tools/Chrono.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "proxy/Counters.h"
#include "proxy/events/CloseEvent.h"
#include "proxy/events/LoginEvent.h"
-#include "proxy/log/AccessLog.h"
#include "proxy/Miner.h"
#include "proxy/Stats.h"
+#include
+#include
+#include
+#include
+
+
xmrig::AccessLog::AccessLog(Controller *controller) :
m_file(-1)
{
@@ -54,9 +54,7 @@ xmrig::AccessLog::AccessLog(Controller *controller) :
}
-xmrig::AccessLog::~AccessLog()
-{
-}
+xmrig::AccessLog::~AccessLog() = default;
void xmrig::AccessLog::onEvent(IEvent *event)
@@ -67,19 +65,22 @@ void xmrig::AccessLog::onEvent(IEvent *event)
switch (event->type())
{
- case IEvent::LoginType: {
+ case IEvent::LoginType:
+ {
auto e = static_cast(event);
- write("#%" PRId64 " login: %s, \"%s\", ua: \"%s\", count: %" PRIu64, e->miner()->id(), e->miner()->ip(), e->miner()->user().data(), e->miner()->agent().data(), Counters::miners());
+ write("#%" PRId64 " login: %s, \"%s\", flow: \"%s\", ua: \"%s\", count: %" PRIu64,
+ e->miner()->id(), e->miner()->ip(), e->miner()->user().data(), e->flow.data(), e->miner()->agent().data(), Counters::miners());
}
break;
- case IEvent::CloseType: {
+ case IEvent::CloseType:
+ {
auto e = static_cast(event);
if (e->miner()->mapperId() == -1) {
break;
}
- const double time = (Chrono::currentMSecsSinceEpoch() - e->miner()->timestamp()) / 1000.0;
+ const double time = static_cast(Chrono::currentMSecsSinceEpoch() - e->miner()->timestamp()) / 1000.0;
write("#%" PRId64 " close: %s, \"%s\", time: %03.1fs, rx/tx: %" PRIu64 "/%" PRIu64 ", count: %" PRIu64,
e->miner()->id(), e->miner()->ip(), e->miner()->user().data(), time, e->miner()->rx(), e->miner()->tx(), Counters::miners());
@@ -112,7 +113,7 @@ void xmrig::AccessLog::write(const char *fmt, ...)
va_start(args, fmt);
time_t now = time(nullptr);
- tm stime;
+ tm stime{};
# ifdef _WIN32
localtime_s(&stime, &now);
@@ -133,7 +134,7 @@ void xmrig::AccessLog::write(const char *fmt, ...)
buf[size] = '\n';
uv_buf_t ubuf = uv_buf_init(buf, (unsigned int) size + 1);
- uv_fs_t *req = new uv_fs_t;
+ auto req = new uv_fs_t;
req->data = ubuf.base;
uv_fs_write(uv_default_loop(), req, m_file, &ubuf, 1, 0, AccessLog::onWrite);
diff --git a/src/proxy/log/AccessLog.h b/src/proxy/log/AccessLog.h
index f2adfe0..db8525a 100644
--- a/src/proxy/log/AccessLog.h
+++ b/src/proxy/log/AccessLog.h
@@ -29,7 +29,7 @@
#include "proxy/interfaces/IEventListener.h"
-typedef struct uv_fs_s uv_fs_t;
+using uv_fs_t = struct uv_fs_s;
class Stats;
diff --git a/src/proxy/splitters/nicehash/NonceSplitter.cpp b/src/proxy/splitters/nicehash/NonceSplitter.cpp
index ab4dbcf..8342183 100644
--- a/src/proxy/splitters/nicehash/NonceSplitter.cpp
+++ b/src/proxy/splitters/nicehash/NonceSplitter.cpp
@@ -71,7 +71,7 @@ xmrig::Upstreams xmrig::NonceSplitter::upstreams() const
}
}
- return Upstreams(active, sleep, m_upstreams.size(), Counters::miners());
+ return Upstreams(active, sleep, m_upstreams.size());
}
@@ -100,13 +100,14 @@ void xmrig::NonceSplitter::gc()
void xmrig::NonceSplitter::printConnections()
{
- const Upstreams info = upstreams();
+ const auto info = upstreams();
+ const auto ratio = info.ratio(Counters::miners());
LOG_INFO("\x1B[01;32m* \x1B[01;37mupstreams\x1B[0m" LABEL("active") "%s%" PRIu64 "\x1B[0m" LABEL("sleep") "\x1B[01;37m%" PRIu64 "\x1B[0m" LABEL("error") "%s%" PRIu64 "\x1B[0m" LABEL("total") "\x1B[01;37m%" PRIu64,
info.active ? "\x1B[01;32m" : "\x1B[01;31m", info.active, info.sleep, info.error ? "\x1B[01;31m" : "\x1B[01;37m", info.error, info.total);
LOG_INFO("\x1B[01;32m* \x1B[01;37mminers \x1B[0m" LABEL("active") "%s%" PRIu64 "\x1B[0m" LABEL("max") "\x1B[01;37m%" PRIu64 "\x1B[0m" LABEL("ratio") "%s1:%3.1f",
- Counters::miners() ? "\x1B[01;32m" : "\x1B[01;31m", Counters::miners(), Counters::maxMiners(), (info.ratio > 200 ? "\x1B[01;32m" : "\x1B[01;33m"), info.ratio);
+ Counters::miners() ? "\x1B[01;32m" : "\x1B[01;31m", Counters::miners(), Counters::maxMiners(), (ratio > 200 ? "\x1B[01;32m" : "\x1B[01;33m"), ratio);
}
diff --git a/src/proxy/splitters/simple/SimpleSplitter.cpp b/src/proxy/splitters/simple/SimpleSplitter.cpp
index 0f014fb..8a390bd 100644
--- a/src/proxy/splitters/simple/SimpleSplitter.cpp
+++ b/src/proxy/splitters/simple/SimpleSplitter.cpp
@@ -70,7 +70,7 @@ xmrig::Upstreams xmrig::SimpleSplitter::upstreams() const
}
}
- return Upstreams(active, m_idles.size(), m_upstreams.size(), Counters::miners());
+ return Upstreams(active, m_idles.size(), m_upstreams.size());
}