Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Nov 13, 2019
2 parents 598f04f + 054ecc6 commit 682f1be
Show file tree
Hide file tree
Showing 64 changed files with 1,616 additions and 704 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v5.0.0
- Proxy rebased to latest miner codebase.
- [#1068](https://github.com/xmrig/xmrig/pull/1068) Added support for `self-select` stratum protocol extension.
- [#1227](https://github.com/xmrig/xmrig/pull/1227) Added new algorithm `rx/arq`, RandomX variant for upcoming ArQmA fork.

# v3.2.1
- [#349](https://github.com/xmrig/xmrig-proxy/issues/349) Fixed command line option `--coin`.

Expand Down
10 changes: 7 additions & 3 deletions src/base/api/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ void xmrig::Api::exec(IApiRequest &request)
auto &allocator = request.doc().GetAllocator();

request.accept();
request.reply().AddMember("id", StringRef(m_id), allocator);
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
request.reply().AddMember("id", StringRef(m_id), allocator);
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
request.reply().AddMember("restricted", request.isRestricted(), allocator);

Value features(kArrayType);
# ifdef XMRIG_FEATURE_API
Expand All @@ -139,6 +140,9 @@ void xmrig::Api::exec(IApiRequest &request)
# endif
# ifdef XMRIG_FEATURE_TLS
features.PushBack("tls", allocator);
# endif
# ifdef XMRIG_FEATURE_OPENCL
features.PushBack("opencl", allocator);
# endif
request.reply().AddMember("features", features, allocator);
}
Expand Down
5 changes: 4 additions & 1 deletion src/base/api/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@


#include <vector>
#include <stdint.h>
#include <cstdint>


#include "base/kernel/interfaces/IBaseListener.h"
#include "base/tools/Object.h"


namespace xmrig {
Expand All @@ -47,6 +48,8 @@ class String;
class Api : public IBaseListener
{
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Api)

Api(Base *base);
~Api() override;

Expand Down
13 changes: 12 additions & 1 deletion src/base/base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(HEADERS_BASE
src/base/net/stratum/strategies/FailoverStrategy.h
src/base/net/stratum/strategies/SinglePoolStrategy.h
src/base/net/stratum/SubmitResult.h
src/base/net/stratum/Url.h
src/base/net/tools/RecvBuf.h
src/base/net/tools/Storage.h
src/base/tools/Arguments.h
Expand Down Expand Up @@ -78,6 +79,7 @@ set(SOURCES_BASE
src/base/net/stratum/Pools.cpp
src/base/net/stratum/strategies/FailoverStrategy.cpp
src/base/net/stratum/strategies/SinglePoolStrategy.cpp
src/base/net/stratum/Url.cpp
src/base/tools/Arguments.cpp
src/base/tools/Buffer.cpp
src/base/tools/String.cpp
Expand All @@ -98,7 +100,14 @@ elseif (APPLE)
else()
set(SOURCES_OS
src/base/io/json/Json_unix.cpp
src/base/kernel//Platform_unix.cpp
src/base/kernel/Platform_unix.cpp
)
endif()


if (WITH_HWLOC)
list(APPEND SOURCES_OS
src/base/kernel/Platform_hwloc.cpp
)
endif()

Expand Down Expand Up @@ -130,6 +139,7 @@ if (WITH_HTTP)
src/base/net/http/HttpResponse.h
src/base/net/http/HttpServer.h
src/base/net/stratum/DaemonClient.h
src/base/net/stratum/SelfSelectClient.h
src/base/net/tools/TcpServer.h
)

Expand All @@ -145,6 +155,7 @@ if (WITH_HTTP)
src/base/net/http/HttpResponse.cpp
src/base/net/http/HttpServer.cpp
src/base/net/stratum/DaemonClient.cpp
src/base/net/stratum/SelfSelectClient.cpp
src/base/net/tools/TcpServer.cpp
)

Expand Down
21 changes: 21 additions & 0 deletions src/base/io/json/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "rapidjson/document.h"


#include <cassert>


namespace xmrig {

static const rapidjson::Value kNullValue;
Expand All @@ -36,6 +39,8 @@ static const rapidjson::Value kNullValue;

bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsBool()) {
return i->value.GetBool();
Expand All @@ -47,6 +52,8 @@ bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool def

const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsString()) {
return i->value.GetString();
Expand All @@ -58,6 +65,8 @@ const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key,

const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const char *key)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsArray()) {
return i->value;
Expand All @@ -69,6 +78,8 @@ const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const

const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, const char *key)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsObject()) {
return i->value;
Expand All @@ -80,6 +91,8 @@ const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, cons

const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const char *key)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd()) {
return i->value;
Expand All @@ -91,6 +104,8 @@ const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const

int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsInt()) {
return i->value.GetInt();
Expand All @@ -102,6 +117,8 @@ int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaul

int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsInt64()) {
return i->value.GetInt64();
Expand All @@ -113,6 +130,8 @@ int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int6

uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsUint64()) {
return i->value.GetUint64();
Expand All @@ -124,6 +143,8 @@ uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, ui

unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue)
{
assert(obj.IsObject());

auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsUint()) {
return i->value.GetUint();
Expand Down
17 changes: 9 additions & 8 deletions src/base/io/log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@


#include <algorithm>
#include <cstring>
#include <ctime>
#include <mutex>
#include <string.h>
#include <string>
#include <time.h>
#include <uv.h>
#include <vector>


#include "base/io/log/Log.h"
#include "base/kernel/interfaces/ILogBackend.h"
#include "base/tools/Chrono.h"
#include "base/tools/Object.h"


namespace xmrig {
Expand All @@ -67,10 +68,10 @@ static const char *colors_map[] = {
class LogPrivate
{
public:
inline LogPrivate() :
m_buf()
{
}
XMRIG_DISABLE_COPY_MOVE(LogPrivate)


LogPrivate() = default;


inline ~LogPrivate()
Expand Down Expand Up @@ -134,7 +135,7 @@ class LogPrivate

const uint64_t ms = Chrono::currentMSecsSinceEpoch();
time_t now = ms / 1000;
tm stime;
tm stime{};

# ifdef _WIN32
localtime_s(&stime, &now);
Expand Down Expand Up @@ -188,7 +189,7 @@ class LogPrivate
}


char m_buf[4096];
char m_buf[4096]{};
std::mutex m_mutex;
std::vector<ILogBackend*> m_backends;
};
Expand Down
2 changes: 2 additions & 0 deletions src/base/io/log/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Log
#define WHITE_S CSI "0;37m" // another name for LT.GRAY
#define WHITE_BOLD_S CSI "1;37m" // actually white

#define GREEN_BG_BOLD_S CSI "42;1m"
#define BLUE_BG_S CSI "44m"
#define BLUE_BG_BOLD_S CSI "44;1m"
#define MAGENTA_BG_S CSI "45m"
Expand All @@ -107,6 +108,7 @@ class Log
#define WHITE(x) WHITE_S x CLEAR
#define WHITE_BOLD(x) WHITE_BOLD_S x CLEAR

#define GREEN_BG_BOLD(x) GREEN_BG_BOLD_S x CLEAR
#define BLUE_BG(x) BLUE_BG_S x CLEAR
#define BLUE_BG_BOLD(x) BLUE_BG_BOLD_S x CLEAR
#define MAGENTA_BG(x) MAGENTA_BG_S x CLEAR
Expand Down
12 changes: 8 additions & 4 deletions src/base/io/log/backends/ConsoleLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ xmrig::ConsoleLog::ConsoleLog()
}

uv_tty_set_mode(m_tty, UV_TTY_MODE_NORMAL);
m_stream = reinterpret_cast<uv_stream_t*>(m_tty);

# ifdef WIN32
m_stream = reinterpret_cast<uv_stream_t*>(m_tty);

HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE) {
DWORD mode = 0;
Expand All @@ -76,9 +77,6 @@ void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool c

# ifdef _WIN32
uv_buf_t buf = uv_buf_init(const_cast<char *>(line), static_cast<unsigned int>(size));
# else
uv_buf_t buf = uv_buf_init(const_cast<char *>(line), size);
# endif

if (!isWritable()) {
fputs(line, stdout);
Expand All @@ -87,6 +85,10 @@ void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool c
else {
uv_try_write(m_stream, &buf, 1);
}
# else
fputs(line, stdout);
fflush(stdout);
# endif
}


Expand All @@ -97,6 +99,7 @@ bool xmrig::ConsoleLog::isSupported() const
}


#ifdef WIN32
bool xmrig::ConsoleLog::isWritable() const
{
if (!m_stream || uv_is_writable(m_stream) != 1) {
Expand All @@ -105,3 +108,4 @@ bool xmrig::ConsoleLog::isWritable() const

return isSupported();
}
#endif
6 changes: 5 additions & 1 deletion src/base/io/log/backends/ConsoleLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ class ConsoleLog : public ILogBackend

private:
bool isSupported() const;

uv_tty_t *m_tty = nullptr;

# ifdef _WIN32
bool isWritable() const;

uv_stream_t *m_stream = nullptr;
uv_tty_t *m_tty = nullptr;
# endif
};


Expand Down
Loading

0 comments on commit 682f1be

Please sign in to comment.