Merge commit

This commit is contained in:
MoneroOcean 2019-01-15 12:43:19 -08:00
commit 495d447cab
68 changed files with 1560 additions and 407 deletions

View file

@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 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
@ -36,7 +37,7 @@
char Platform::m_defaultConfigName[520] = { 0 };
xmrig::c_str Platform::m_userAgent;
xmrig::String Platform::m_userAgent;
const char *Platform::defaultConfigName()

View file

@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 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
@ -28,7 +29,7 @@
#include <stdint.h>
#include "common/utils/c_str.h"
#include "base/tools/String.h"
class Platform
@ -36,7 +37,9 @@ class Platform
public:
static bool setThreadAffinity(uint64_t cpu_id);
static const char *defaultConfigName();
static uint32_t setTimerResolution(uint32_t resolution);
static void init(const char *userAgent);
static void restoreTimerResolution();
static void setProcessPriority(int priority);
static void setThreadPriority(int priority);
@ -46,7 +49,7 @@ private:
static char *createUserAgent();
static char m_defaultConfigName[520];
static xmrig::c_str m_userAgent;
static xmrig::String m_userAgent;
};

View file

@ -40,15 +40,20 @@
char *Platform::createUserAgent()
{
const size_t max = 160;
constexpr const size_t max = 256;
char *buf = static_cast<char *>(malloc(max));
char *buf = new char[max]();
int length = snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s", APP_NAME, APP_VERSION, uv_version_string());
# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
# else
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
# endif
# ifdef __clang__
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
# elif defined(__GNUC__)
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# endif
return buf;
@ -65,9 +70,19 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
}
uint32_t Platform::setTimerResolution(uint32_t resolution)
{
return resolution;
}
void Platform::restoreTimerResolution()
{
}
void Platform::setProcessPriority(int priority)
{
}

View file

@ -54,9 +54,9 @@ typedef cpuset_t cpu_set_t;
char *Platform::createUserAgent()
{
const size_t max = 160;
constexpr const size_t max = 256;
char *buf = static_cast<char *>(malloc(max));
char *buf = new char[max]();
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION);
# if defined(__x86_64__)
@ -70,7 +70,9 @@ char *Platform::createUserAgent()
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
# endif
# ifdef __GNUC__
# ifdef __clang__
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
# elif defined(__GNUC__)
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# endif
@ -92,6 +94,17 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
}
uint32_t Platform::setTimerResolution(uint32_t resolution)
{
return resolution;
}
void Platform::restoreTimerResolution()
{
}
void Platform::setProcessPriority(int priority)
{
}

View file

@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 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
@ -22,6 +23,7 @@
*/
#include <algorithm>
#include <winsock2.h>
#include <windows.h>
#include <uv.h>
@ -37,6 +39,11 @@
#endif
#ifdef XMRIG_AMD_PROJECT
static uint32_t timerResolution = 0;
#endif
static inline OSVERSIONINFOEX winOsVersion()
{
typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO);
@ -58,9 +65,9 @@ static inline OSVERSIONINFOEX winOsVersion()
char *Platform::createUserAgent()
{
const auto osver = winOsVersion();
const size_t max = 160;
constexpr const size_t max = 256;
char *buf = static_cast<char *>(malloc(max));
char *buf = new char[max]();
int length = snprintf(buf, max, "%s/%s (Windows NT %lu.%lu", APP_NAME, APP_VERSION, osver.dwMajorVersion, osver.dwMinorVersion);
# if defined(__x86_64__) || defined(_M_AMD64)
@ -94,6 +101,34 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
}
uint32_t Platform::setTimerResolution(uint32_t resolution)
{
# ifdef XMRIG_AMD_PROJECT
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
return 0;
}
timerResolution = std::min<uint32_t>(std::max<uint32_t>(tc.wPeriodMin, resolution), tc.wPeriodMax);
return timeBeginPeriod(timerResolution) == TIMERR_NOERROR ? timerResolution : 0;
# else
return resolution;
# endif
}
void Platform::restoreTimerResolution()
{
# ifdef XMRIG_AMD_PROJECT
if (timerResolution) {
timeEndPeriod(timerResolution);
}
# endif
}
void Platform::setProcessPriority(int priority)
{
if (priority == -1) {
@ -121,6 +156,7 @@ void Platform::setProcessPriority(int priority)
case 5:
prio = REALTIME_PRIORITY_CLASS;
break;
default:
break;

View file

@ -177,8 +177,11 @@ void xmrig::CommonConfig::printVersions()
int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
# else
memset(buf, 0, 16);
# if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS)
int length = 0;
# endif
# endif
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
{
@ -283,16 +286,16 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
break;
case KeepAliveKey: /* --keepalive */
m_pools.back().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
break;
case TlsKey: /* --tls */
m_pools.back().setTLS(enable);
currentPool().setTLS(enable);
break;
# ifndef XMRIG_PROXY_PROJECT
case NicehashKey: /* --nicehash */
m_pools.back().setNicehash(enable);
currentPool().setNicehash(enable);
break;
# endif
@ -340,13 +343,15 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
break;
case UserpassKey: /* --userpass */
if (!m_pools.back().setUserpass(arg)) {
if (!currentPool().setUserpass(arg)) {
return false;
}
break;
case UrlKey: /* --url */
fixup();
if (m_pools.size() > 1 || m_pools[0].isValid()) {
Pool pool(arg);
@ -365,23 +370,23 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
break;
case UserKey: /* --user */
m_pools.back().setUser(arg);
currentPool().setUser(arg);
break;
case PasswordKey: /* --pass */
m_pools.back().setPassword(arg);
currentPool().setPassword(arg);
break;
case RigIdKey: /* --rig-id */
m_pools.back().setRigId(arg);
currentPool().setRigId(arg);
break;
case FingerprintKey: /* --tls-fingerprint */
m_pools.back().setFingerprint(arg);
currentPool().setFingerprint(arg);
break;
case VariantKey: /* --variant */
m_pools.back().algorithm().parseVariant(arg);
currentPool().algorithm().parseVariant(arg);
break;
case LogFileKey: /* --log-file */
@ -407,7 +412,7 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
case RetriesKey: /* --retries */
case RetryPauseKey: /* --retry-pause */
case ApiPort: /* --api-port */
case PrintTimeKey: /* --cpu-priority */
case PrintTimeKey: /* --print-time */
return parseUint64(key, strtol(arg, nullptr, 10));
case BackgroundKey: /* --background */
@ -473,11 +478,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
break;
case KeepAliveKey: /* --keepalive */
m_pools.back().setKeepAlive(arg);
currentPool().setKeepAlive(arg);
break;
case VariantKey: /* --variant */
m_pools.back().algorithm().parseVariant(arg);
currentPool().algorithm().parseVariant(arg);
break;
case DonateLevelKey: /* --donate-level */
@ -510,3 +515,30 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
return true;
}
Pool &xmrig::CommonConfig::currentPool()
{
fixup();
return m_pools.back();
}
void xmrig::CommonConfig::fixup()
{
if (m_state == NoneState) {
return;
}
if (m_pools.empty()) {
if (!m_activePools.empty()) {
std::swap(m_pools, m_activePools);
}
else {
m_pools.push_back(Pool());
}
m_state = NoneState;
}
}

View file

@ -118,9 +118,11 @@ protected:
private:
bool parseInt(int key, int arg);
Pool &currentPool();
void fixup();
};
} /* namespace xmrig */
#endif /* __COMMONCONFIG_H__ */
#endif /* XMRIG_COMMONCONFIG_H */

View file

@ -5,7 +5,7 @@
* 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 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
@ -50,6 +50,7 @@
#include "rapidjson/filereadstream.h"
bool xmrig::ConfigLoader::m_done = false;
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr;
@ -283,12 +284,16 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
void xmrig::ConfigLoader::showUsage()
{
m_done = true;
printf(usage);
}
void xmrig::ConfigLoader::showVersion()
{
m_done = true;
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
# if defined(__clang__)

View file

@ -5,7 +5,7 @@
* 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 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
@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CONFIGLOADER_H__
#define __CONFIGLOADER_H__
#ifndef XMRIG_CONFIGLOADER_H
#define XMRIG_CONFIGLOADER_H
#include <stdint.h>
@ -53,6 +53,8 @@ public:
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener);
static void release();
static inline bool isDone() { return m_done; }
private:
static bool getJSON(const char *fileName, rapidjson::Document &doc);
static bool parseArg(IConfig *config, int key, const char *arg);
@ -60,6 +62,7 @@ private:
static void showUsage();
static void showVersion();
static bool m_done;
static ConfigWatcher *m_watcher;
static IConfigCreator *m_creator;
static IWatcherListener *m_listener;
@ -68,4 +71,4 @@ private:
} /* namespace xmrig */
#endif /* __CONFIGLOADER_H__ */
#endif /* XMRIG_CONFIGLOADER_H */

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -63,6 +63,8 @@ static AlgoData const algorithms[] = {
{ "cryptonight/xao", "cn/xao", xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO },
{ "cryptonight/rto", "cn/rto", xmrig::CRYPTONIGHT, xmrig::VARIANT_RTO },
{ "cryptonight/2", "cn/2", xmrig::CRYPTONIGHT, xmrig::VARIANT_2 },
{ "cryptonight/half", "cn/half", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
{ "cryptonight/xtlv9", "cn/xtlv9", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
# ifndef XMRIG_NO_AEON
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
@ -110,9 +112,13 @@ static const char *variants[] = {
"xao",
"rto",
"2",
"half"
};
static_assert(xmrig::VARIANT_MAX == ARRAY_SIZE(variants), "variants size mismatch");
bool xmrig::Algorithm::isValid() const
{
if (m_algo == INVALID_ALGO) {
@ -145,10 +151,16 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
m_variant = VARIANT_AUTO;
assert(algo != nullptr);
if (algo == nullptr) {
if (algo == nullptr || strlen(algo) < 1) {
return;
}
if (*algo == '!') {
m_flags |= Forced;
return parseAlgorithm(algo + 1);
}
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) {
m_algo = algorithms[i].algo;
@ -167,12 +179,26 @@ void xmrig::Algorithm::parseVariant(const char *variant)
{
m_variant = VARIANT_AUTO;
if (variant == nullptr || strlen(variant) < 1) {
return;
}
if (*variant == '!') {
m_flags |= Forced;
return parseVariant(variant + 1);
}
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
if (strcasecmp(variant, variants[i]) == 0) {
m_variant = static_cast<Variant>(i);
break;
return;
}
}
if (strcasecmp(variant, "xtlv9") == 0) {
m_variant = VARIANT_HALF;
}
}

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -40,12 +40,19 @@ namespace xmrig {
class Algorithm
{
public:
enum Flags {
None = 0,
Forced = 1
};
inline Algorithm() :
m_algo(INVALID_ALGO),
m_flags(0),
m_variant(VARIANT_AUTO)
{}
inline Algorithm(Algo algo, Variant variant = VARIANT_AUTO) :
inline Algorithm(Algo algo, Variant variant) :
m_flags(0),
m_variant(variant)
{
setAlgo(algo);
@ -54,19 +61,23 @@ public:
// constructs Algorithm from PerfAlgo
Algorithm(const xmrig::PerfAlgo);
inline Algorithm(const char *algo)
inline Algorithm(const char *algo) :
m_flags(0)
{
parseAlgorithm(algo);
}
bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
inline Algo algo() const { return m_algo; }
inline Algo algo() const { return m_algo; }
inline bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
inline bool isForced() const { return m_flags & Forced; }
inline const char *name() const { return name(false); }
inline const char *shortName() const { return name(true); }
inline int flags() const { return m_flags; }
inline Variant variant() const { return m_variant; }
inline void setVariant(Variant variant) { m_variant = variant; }
xmrig::PerfAlgo perf_algo() const; // returns PerfAlgo that corresponds to current Algorithm
inline const char *name() const { return name(false); }
inline const char *shortName() const { return name(true); }
static const char *perfAlgoName(xmrig::PerfAlgo); // returns string name of the PerfAlgo
inline Variant variant() const { return m_variant; }
inline void setVariant(Variant variant) { m_variant = variant; }
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
@ -86,6 +97,7 @@ private:
const char *name(bool shortName) const;
Algo m_algo;
int m_flags;
Variant m_variant;
};

View file

@ -100,16 +100,23 @@ public:
OclCompModeKey = 1410,
// xmrig-proxy
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
TlsBindKey = 1108,
TlsCertKey = 1109,
TlsCertKeyKey = 1110,
TlsDHparamKey = 1111,
TlsCiphersKey = 1112,
TlsCipherSuitesKey = 1113,
TlsProtocolsKey = 1114,
// xmrig nvidia
CudaMaxThreadsKey = 1200,

View file

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LOG_H__
#define __LOG_H__
#ifndef XMRIG_LOG_H
#define XMRIG_LOG_H
#include <assert.h>
@ -39,7 +39,7 @@ public:
static inline Log* i() { if (!m_self) { defaultInit(); } return m_self; }
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
static inline void init() { if (!m_self) { new Log(); } }
static inline void release() { assert(m_self != nullptr); delete m_self; }
static inline void release() { delete m_self; }
void message(ILogBackend::Level level, const char* fmt, ...);
void text(const char* fmt, ...);
@ -98,4 +98,4 @@ private:
# define LOG_DEBUG_WARN(x, ...)
#endif
#endif /* __LOG_H__ */
#endif /* XMRIG_LOG_H */

View file

@ -5,8 +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 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -215,6 +215,12 @@ const char *Client::tlsVersion() const
int64_t Client::submit(const JobResult &result)
{
# ifndef XMRIG_PROXY_PROJECT
if (result.clientId != m_rpcId) {
return -1;
}
# endif
using namespace rapidjson;
# ifdef XMRIG_PROXY_PROJECT
@ -362,6 +368,8 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
// retarget workers for possible new Algo profile (same algo profile is not reapplied)
Workers::switch_algo(job.algorithm());
m_job.setClientId(m_rpcId);
if (m_job != job) {
m_jobs++;
m_job = std::move(job);

View file

@ -5,8 +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 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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

View file

@ -5,7 +5,7 @@
* 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 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
@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ID_H__
#define __ID_H__
#ifndef XMRIG_ID_H
#define XMRIG_ID_H
#include <string.h>
@ -95,4 +95,4 @@ private:
} /* namespace xmrig */
#endif /* __ID_H__ */
#endif /* XMRIG_ID_H */

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -92,6 +92,12 @@ Job::~Job()
}
bool Job::isEqual(const Job &other) const
{
return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
}
bool Job::setBlob(const char *blob)
{
if (!blob) {
@ -120,6 +126,15 @@ bool Job::setBlob(const char *blob)
m_algorithm.setVariant(variant());
}
if (!m_algorithm.isForced()) {
if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
m_algorithm.setVariant(xmrig::VARIANT_HALF);
}
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) {
m_algorithm.setVariant(xmrig::VARIANT_HALF);
}
}
# ifdef XMRIG_PROXY_PROJECT
memset(m_rawBlob, 0, sizeof(m_rawBlob));
memcpy(m_rawBlob, blob, m_size * 2);
@ -221,18 +236,6 @@ char *Job::toHex(const unsigned char* in, unsigned int len)
#endif
bool Job::operator==(const Job &other) const
{
return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
}
bool Job::operator!=(const Job &other) const
{
return m_id != other.m_id || memcmp(m_blob, other.m_blob, sizeof(m_blob)) != 0;
}
xmrig::Variant Job::variant() const
{
using namespace xmrig;

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -43,6 +43,7 @@ public:
Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmrig::Id &clientId);
~Job();
bool isEqual(const Job &other) const;
bool setBlob(const char *blob);
void setRawBlob(const uint8_t *blob, const size_t size); // for algo benchmarking
bool setTarget(const char *target);
@ -85,8 +86,8 @@ public:
static char *toHex(const unsigned char* in, unsigned int len);
# endif
bool operator==(const Job &other) const;
bool operator!=(const Job &other) const;
inline bool operator==(const Job &other) const { return isEqual(other); }
inline bool operator!=(const Job &other) const { return !isEqual(other); }
private:
xmrig::Variant variant() const;

View file

@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -317,23 +317,39 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
m_nicehash = true;
bool valid = true;
if (m_host.contains("cryptonight.") && m_port == 3355) {
valid = m_algorithm.algo() == CRYPTONIGHT;
switch (m_port) {
case 3355:
case 33355:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonight.");
m_algorithm.setVariant(VARIANT_0);
}
else if (m_host.contains("cryptonightv7.") && m_port == 3363) {
valid = m_algorithm.algo() == CRYPTONIGHT;
break;
case 3363:
case 33363:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv7.");
m_algorithm.setVariant(VARIANT_1);
}
else if (m_host.contains("cryptonightheavy.") && m_port == 3364) {
valid = m_algorithm.algo() == CRYPTONIGHT_HEAVY;
break;
case 3364:
valid = m_algorithm.algo() == CRYPTONIGHT_HEAVY && m_host.contains("cryptonightheavy.");
m_algorithm.setVariant(VARIANT_0);
break;
case 3367:
case 33367:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv8.");
m_algorithm.setVariant(VARIANT_2);
break;
default:
break;
}
if (!valid) {
m_algorithm.setAlgo(INVALID_ALGO);
}
m_tls = m_port > 33000;
return;
}
@ -344,7 +360,7 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
if (m_host.contains("xmr.pool.")) {
valid = m_algorithm.algo() == CRYPTONIGHT;
m_algorithm.setVariant(m_port == 45700 ? VARIANT_1 : VARIANT_0);
m_algorithm.setVariant(m_port == 45700 ? VARIANT_AUTO : VARIANT_0);
}
else if (m_host.contains("aeon.pool.") && m_port == 45690) {
valid = m_algorithm.algo() == CRYPTONIGHT_LITE;

View file

@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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

View file

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_TLS_H
#define XMRIG_TLS_H
#ifndef XMRIG_CLIENT_TLS_H
#define XMRIG_CLIENT_TLS_H
#include <openssl/ssl.h>
@ -59,4 +59,4 @@ private:
};
#endif /* XMRIG_TLS_H */
#endif /* XMRIG_CLIENT_TLS_H */

View file

@ -21,82 +21,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __C_STR_H__
#define __C_STR_H__
#ifndef XMRIG_C_STR_H
#define XMRIG_C_STR_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "base/tools/String.h"
namespace xmrig {
/**
* @brief Simple C string wrapper.
*
* 1. I know about std:string.
* 2. For some reason I prefer don't use std:string in miner, eg because of file size of MSYS2 builds.
*/
class c_str
{
public:
inline c_str() : m_data(nullptr) {}
inline c_str(c_str &&other) { m_data = other.m_data; other.m_data = nullptr; }
inline c_str(const c_str &other) : m_data(nullptr) { set(other.data()); }
inline c_str(const char *str) : m_data(nullptr) { set(str); }
inline ~c_str() { free(m_data); }
inline void set(const char *str)
{
free(m_data);
m_data = str != nullptr ? strdup(str) : nullptr;
}
inline void set(char *str)
{
free(m_data);
m_data = str;
}
inline bool isEqual(const char *str) const
{
return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && m_data == nullptr);
}
inline bool contains(const char *str) const
{
return strstr(m_data, str) != nullptr;
}
inline bool isNull() const { return m_data == nullptr; }
inline const char *data() const { return m_data; }
inline size_t size() const { return m_data == nullptr ? 0 : strlen(m_data); }
inline bool operator!=(const c_str &str) const { return !isEqual(str.data()); }
inline bool operator!=(const char *str) const { return !isEqual(str); }
inline bool operator==(const c_str &str) const { return isEqual(str.data()); }
inline bool operator==(const char *str) const { return isEqual(str); }
inline c_str &operator=(char *str) { set(str); return *this; }
inline c_str &operator=(const c_str &str) { set(str.data()); return *this; }
inline c_str &operator=(const char *str) { set(str); return *this; }
private:
char *m_data;
};
typedef String c_str;
} /* namespace xmrig */
#endif /* __C_STR_H__ */
#endif /* XMRIG_C_STR_H */

View file

@ -31,7 +31,7 @@
namespace xmrig {
static inline int64_t currentMSecsSinceEpoch()
static inline int64_t steadyTimestamp()
{
using namespace std::chrono;
if (high_resolution_clock::is_steady) {
@ -42,6 +42,14 @@ static inline int64_t currentMSecsSinceEpoch()
}
static inline int64_t currentMSecsSinceEpoch()
{
using namespace std::chrono;
return time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
}
} /* namespace xmrig */
#endif /* XMRIG_TIMESTAMP_H */

View file

@ -5,8 +5,9 @@
* 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 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2018 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -80,6 +81,7 @@ enum Variant {
VARIANT_XAO = 6, // Modified CryptoNight variant 0 (Alloy only)
VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only)
VARIANT_2 = 8, // CryptoNight variant 2
VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite)
VARIANT_MAX
};
@ -111,6 +113,7 @@ enum Assembly {
ASM_AUTO,
ASM_INTEL,
ASM_RYZEN,
ASM_BULLDOZER,
ASM_MAX
};