diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4655cf348..11b82cbf7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# v2.15.4-beta
+- Added global uptime and extended connection information in API.
+- API now return current algorithm instead of global algorithm specified in config.
+- This version also include all changes from stable version v2.14.4.
+
# v2.15.3-beta
- [#1014](https://github.com/xmrig/xmrig/issues/1014) Fixed regression, default value for `algo` option was not applied.
@@ -16,6 +21,13 @@
- Added new option `donate-over-proxy`.
- Added real graceful exit.
+# v2.14.4
+- [#992](https://github.com/xmrig/xmrig/pull/992) Fixed compilation with Clang 3.5.
+- [#1012](https://github.com/xmrig/xmrig/pull/1012) Fixed compilation with Clang 9.0.
+- In HTTP API for unknown hashrate now used `null` instead of `0.0`.
+- Fixed MSVC 2019 version detection.
+- Removed obsolete automatic variants.
+
# v2.14.1
* [#975](https://github.com/xmrig/xmrig/issues/975) Fixed crash on Linux if double thread mode used.
diff --git a/README.md b/README.md
index ee16862aa..5b6dc7a03 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin
* This is the **CPU-mining** version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia) and [AMD GPU version]( https://github.com/xmrig/xmrig-amd).
* [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases.
-
+
#### Table of contents
* [Features](#features)
diff --git a/src/api/Api.cpp b/src/api/Api.cpp
index d1bac212e..a11325f32 100644
--- a/src/api/Api.cpp
+++ b/src/api/Api.cpp
@@ -38,6 +38,7 @@
#include "api/v1/ApiRouter.h"
#include "base/kernel/Base.h"
#include "base/tools/Buffer.h"
+#include "base/tools/Chrono.h"
#include "common/crypto/keccak.h"
#include "core/config/Config.h"
#include "core/Controller.h"
@@ -53,7 +54,8 @@ xmrig::Api::Api(Base *base) :
m_base(base),
m_id(),
m_workerId(),
- m_httpd(nullptr)
+ m_httpd(nullptr),
+ m_timestamp(Chrono::steadyMSecs())
{
base->addListener(this);
@@ -118,9 +120,12 @@ void xmrig::Api::exec(IApiRequest &request)
using namespace rapidjson;
if (request.method() == IApiRequest::METHOD_GET && (request.url() == "/1/summary" || request.url() == "/api.json")) {
+ auto &allocator = request.doc().GetAllocator();
+
request.accept();
- request.reply().AddMember("id", StringRef(m_id), request.doc().GetAllocator());
- request.reply().AddMember("worker_id", StringRef(m_workerId), request.doc().GetAllocator());;
+ request.reply().AddMember("id", StringRef(m_id), allocator);
+ request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
+ request.reply().AddMember("uptime", (Chrono::steadyMSecs() - m_timestamp) / 1000, allocator);
}
for (IApiListener *listener : m_listeners) {
diff --git a/src/api/Api.h b/src/api/Api.h
index 0c7fac524..eef57c3a4 100644
--- a/src/api/Api.h
+++ b/src/api/Api.h
@@ -27,6 +27,7 @@
#include
+#include
#include "base/kernel/interfaces/IBaseListener.h"
@@ -72,6 +73,7 @@ private:
char m_workerId[128];
Httpd *m_httpd;
std::vector m_listeners;
+ uint64_t m_timestamp;
};
diff --git a/src/api/v1/ApiRouter.cpp b/src/api/v1/ApiRouter.cpp
index 1f3641c37..d066b0b1e 100644
--- a/src/api/v1/ApiRouter.cpp
+++ b/src/api/v1/ApiRouter.cpp
@@ -40,13 +40,15 @@
#include "workers/Workers.h"
-static inline double normalize(double d)
+static inline rapidjson::Value normalize(double d)
{
+ using namespace rapidjson;
+
if (!isnormal(d)) {
- return 0.0;
+ return Value(kNullType);
}
- return floor(d * 100.0) / 100.0;
+ return Value(floor(d * 100.0) / 100.0);
}
@@ -142,7 +144,6 @@ void xmrig::ApiRouter::getMiner(rapidjson::Value &reply, rapidjson::Document &do
reply.AddMember("kind", APP_KIND, allocator);
reply.AddMember("ua", StringRef(Platform::userAgent()), allocator);
reply.AddMember("cpu", cpu, allocator);
- reply.AddMember("algo", StringRef(m_base->config()->algorithm().shortName()), allocator);
reply.AddMember("hugepages", Workers::hugePages() > 0, allocator);
reply.AddMember("donate_level", m_base->config()->pools().donateLevel(), allocator);
}
diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp
index 663818e2b..1f1cd4139 100644
--- a/src/base/net/stratum/Job.cpp
+++ b/src/base/net/stratum/Job.cpp
@@ -102,24 +102,6 @@ bool xmrig::Job::setBlob(const char *blob)
m_algorithm.setVariant(variant());
}
- if (!m_algorithm.isForced()) {
- if (m_algorithm.variant() == VARIANT_XTL && m_blob[0] >= 9) {
- m_algorithm.setVariant(VARIANT_HALF);
- }
- else if (m_algorithm.variant() == VARIANT_MSR && m_blob[0] >= 8) {
- m_algorithm.setVariant(VARIANT_HALF);
- }
- else if (m_algorithm.variant() == VARIANT_WOW && m_blob[0] < 11) {
- m_algorithm.setVariant(VARIANT_2);
- }
- else if (m_algorithm.variant() == VARIANT_RWZ && m_blob[0] < 12) {
- m_algorithm.setVariant(VARIANT_2);
- }
- else if (m_algorithm.variant() == VARIANT_ZLS && m_blob[0] < 8) {
- m_algorithm.setVariant(VARIANT_2);
- }
- }
-
# ifdef XMRIG_PROXY_PROJECT
memset(m_rawBlob, 0, sizeof(m_rawBlob));
memcpy(m_rawBlob, blob, m_size * 2);
diff --git a/src/base/net/stratum/strategies/FailoverStrategy.cpp b/src/base/net/stratum/strategies/FailoverStrategy.cpp
index b89cd955a..d52472293 100644
--- a/src/base/net/stratum/strategies/FailoverStrategy.cpp
+++ b/src/base/net/stratum/strategies/FailoverStrategy.cpp
@@ -89,7 +89,7 @@ void xmrig::FailoverStrategy::add(const Pool &pool)
int64_t xmrig::FailoverStrategy::submit(const JobResult &result)
{
- if (m_active == -1) {
+ if (!isActive()) {
return -1;
}
diff --git a/src/base/net/stratum/strategies/FailoverStrategy.h b/src/base/net/stratum/strategies/FailoverStrategy.h
index 344d815c0..b1fe8bace 100644
--- a/src/base/net/stratum/strategies/FailoverStrategy.h
+++ b/src/base/net/stratum/strategies/FailoverStrategy.h
@@ -52,7 +52,7 @@ public:
protected:
inline bool isActive() const override { return m_active >= 0; }
- inline IClient *client() const override { return active(); }
+ inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; }
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
int64_t submit(const JobResult &result) override;
diff --git a/src/base/tools/String.h b/src/base/tools/String.h
index eb0a18207..2c47d8501 100644
--- a/src/base/tools/String.h
+++ b/src/base/tools/String.h
@@ -80,6 +80,7 @@ public:
inline String &operator=(char *str) { move(str); return *this; }
inline String &operator=(const char *str) { copy(str); return *this; }
inline String &operator=(const String &str) { copy(str); return *this; }
+ inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; }
inline String &operator=(String &&other) { move(std::move(other)); return *this; }
rapidjson::Value toJSON() const;
diff --git a/src/net/Network.cpp b/src/net/Network.cpp
index cc5d59e40..1ab422368 100644
--- a/src/net/Network.cpp
+++ b/src/net/Network.cpp
@@ -53,6 +53,7 @@
xmrig::Network::Network(Controller *controller) :
+ m_controller(controller),
m_donate(nullptr),
m_timer(nullptr)
{
@@ -99,7 +100,7 @@ void xmrig::Network::onActive(IStrategy *strategy, IClient *client)
return;
}
- m_state.setPool(client->pool().host(), client->pool().port(), client->ip());
+ m_state.onActive(client);
const char *tlsVersion = client->tlsVersion();
LOG_INFO(WHITE_BOLD("use %s ") CYAN_BOLD("%s:%d ") GREEN_BOLD("%s") " " BLACK_BOLD("%s"),
@@ -230,12 +231,18 @@ void xmrig::Network::getConnection(rapidjson::Value &reply, rapidjson::Document
using namespace rapidjson;
auto &allocator = doc.GetAllocator();
+ const Algorithm &algo = m_strategy->client()->job().algorithm();
+ reply.AddMember("algo", StringRef((algo.isValid() ? algo : m_controller->config()->algorithm()).shortName()), allocator);
+
Value connection(kObjectType);
- connection.AddMember("pool", StringRef(m_state.pool), allocator);
- connection.AddMember("uptime", m_state.connectionTime(), allocator);
- connection.AddMember("ping", m_state.latency(), allocator);
- connection.AddMember("failures", m_state.failures, allocator);
- connection.AddMember("error_log", Value(kArrayType), allocator);
+ connection.AddMember("pool", StringRef(m_state.pool), allocator);
+ connection.AddMember("ip", m_state.ip().toJSON(), allocator);
+ connection.AddMember("uptime", m_state.connectionTime(), allocator);
+ connection.AddMember("ping", m_state.latency(), allocator);
+ connection.AddMember("failures", m_state.failures, allocator);
+ connection.AddMember("tls", m_state.tls().toJSON(), allocator);
+ connection.AddMember("tls-fingerprint", m_state.fingerprint().toJSON(), allocator);
+ connection.AddMember("error_log", Value(kArrayType), allocator);
reply.AddMember("connection", connection, allocator);
}
diff --git a/src/net/Network.h b/src/net/Network.h
index 079d997a4..eaec9472f 100644
--- a/src/net/Network.h
+++ b/src/net/Network.h
@@ -78,6 +78,7 @@ private:
void getResults(rapidjson::Value &reply, rapidjson::Document &doc) const;
# endif
+ Controller *m_controller;
IStrategy *m_donate;
IStrategy *m_strategy;
NetworkState m_state;
diff --git a/src/net/NetworkState.cpp b/src/net/NetworkState.cpp
index c55422db7..6868f57e2 100644
--- a/src/net/NetworkState.cpp
+++ b/src/net/NetworkState.cpp
@@ -29,6 +29,8 @@
#include
+#include "base/kernel/interfaces/IClient.h"
+#include "base/net/stratum/Pool.h"
#include "base/net/stratum/SubmitResult.h"
#include "base/tools/Chrono.h"
#include "net/NetworkState.h"
@@ -92,23 +94,29 @@ void xmrig::NetworkState::add(const SubmitResult &result, const char *error)
std::sort(topDiff.rbegin(), topDiff.rend());
}
- m_latency.push_back(result.elapsed > 0xFFFF ? 0xFFFF : (uint16_t) result.elapsed);
+ m_latency.push_back(result.elapsed > 0xFFFF ? 0xFFFF : static_cast(result.elapsed));
}
-void xmrig::NetworkState::setPool(const char *host, int port, const char *ip)
+void xmrig::NetworkState::onActive(IClient *client)
{
- snprintf(pool, sizeof(pool) - 1, "%s:%d", host, port);
+ snprintf(pool, sizeof(pool) - 1, "%s:%d", client->pool().host().data(), client->pool().port());
- m_active = true;
+ m_ip = client->ip();
+ m_tls = client->tlsVersion();
+ m_fingerprint = client->tlsFingerprint();
+ m_active = true;
m_connectionTime = Chrono::steadyMSecs();
}
void xmrig::NetworkState::stop()
{
- m_active = false;
- diff = 0;
+ m_active = false;
+ diff = 0;
+ m_ip = nullptr;
+ m_tls = nullptr;
+ m_fingerprint = nullptr;
failures++;
m_latency.clear();
diff --git a/src/net/NetworkState.h b/src/net/NetworkState.h
index cf9a649a0..ce56ec725 100644
--- a/src/net/NetworkState.h
+++ b/src/net/NetworkState.h
@@ -30,9 +30,13 @@
#include
+#include "base/tools/String.h"
+
+
namespace xmrig {
+class IClient;
class SubmitResult;
@@ -41,11 +45,15 @@ class NetworkState
public:
NetworkState();
+ inline const String &fingerprint() const { return m_fingerprint; }
+ inline const String &ip() const { return m_ip; }
+ inline const String &tls() const { return m_tls; }
+
uint32_t avgTime() const;
uint32_t latency() const;
uint64_t connectionTime() const;
void add(const SubmitResult &result, const char *error);
- void setPool(const char *host, int port, const char *ip);
+ void onActive(IClient *client);
void stop();
char pool[256];
@@ -59,6 +67,9 @@ public:
private:
bool m_active;
std::vector m_latency;
+ String m_fingerprint;
+ String m_ip;
+ String m_tls;
uint64_t m_connectionTime;
};
diff --git a/src/version.h b/src/version.h
index 0c9b970a1..384c2513a 100644
--- a/src/version.h
+++ b/src/version.h
@@ -28,7 +28,7 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig CPU miner"
-#define APP_VERSION "2.15.3-beta"
+#define APP_VERSION "2.15.4-evo"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
@@ -36,10 +36,12 @@
#define APP_VER_MAJOR 2
#define APP_VER_MINOR 15
-#define APP_VER_PATCH 3
+#define APP_VER_PATCH 4
#ifdef _MSC_VER
-# if (_MSC_VER >= 1910)
+# if (_MSC_VER >= 1920)
+# define MSVC_VERSION 2019
+# elif (_MSC_VER >= 1910 && _MSC_VER < 1920)
# define MSVC_VERSION 2017
# elif _MSC_VER == 1900
# define MSVC_VERSION 2015