Merge pull request #1964 from xmrig/update-base
Cleanup and refactoring
This commit is contained in:
commit
1d5592f303
121 changed files with 1358 additions and 1449 deletions
|
@ -168,7 +168,7 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
add_definitions(-DXMRIG_MINER_PROJECT)
|
||||
add_definitions(-DXMRIG_MINER_PROJECT -DXMRIG_JSON_SINGLE_LINE_ARRAY)
|
||||
add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE)
|
||||
|
||||
find_package(UV REQUIRED)
|
||||
|
|
|
@ -108,6 +108,13 @@ if (WITH_RANDOMX)
|
|||
remove_definitions(/DXMRIG_FIX_RYZEN)
|
||||
message("-- WITH_MSR=OFF")
|
||||
endif()
|
||||
|
||||
if (WITH_PROFILING)
|
||||
add_definitions(/DXMRIG_FEATURE_PROFILING)
|
||||
|
||||
list(APPEND HEADERS_CRYPTO src/crypto/rx/Profiler.h)
|
||||
list(APPEND SOURCES_CRYPTO src/crypto/rx/Profiler.cpp)
|
||||
endif()
|
||||
else()
|
||||
remove_definitions(/DXMRIG_ALGO_RANDOMX)
|
||||
endif()
|
||||
|
|
32
src/App.cpp
32
src/App.cpp
|
@ -43,17 +43,13 @@
|
|||
|
||||
xmrig::App::App(Process *process)
|
||||
{
|
||||
m_controller = new Controller(process);
|
||||
m_controller = std::make_shared<Controller>(process);
|
||||
}
|
||||
|
||||
|
||||
xmrig::App::~App()
|
||||
{
|
||||
Cpu::release();
|
||||
|
||||
delete m_signals;
|
||||
delete m_console;
|
||||
delete m_controller;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +61,7 @@ int xmrig::App::exec()
|
|||
return 2;
|
||||
}
|
||||
|
||||
m_signals = new Signals(this);
|
||||
m_signals = std::make_shared<Signals>(this);
|
||||
|
||||
int rc = 0;
|
||||
if (background(rc)) {
|
||||
|
@ -78,10 +74,10 @@ int xmrig::App::exec()
|
|||
}
|
||||
|
||||
if (!m_controller->isBackground()) {
|
||||
m_console = new Console(this);
|
||||
m_console = std::make_shared<Console>(this);
|
||||
}
|
||||
|
||||
Summary::print(m_controller);
|
||||
Summary::print(m_controller.get());
|
||||
|
||||
if (m_controller->config()->isDryRun()) {
|
||||
LOG_NOTICE("%s " WHITE_BOLD("OK"), Tags::config());
|
||||
|
@ -115,32 +111,20 @@ void xmrig::App::onSignal(int signum)
|
|||
switch (signum)
|
||||
{
|
||||
case SIGHUP:
|
||||
LOG_WARN("%s " YELLOW("SIGHUP received, exiting"), Tags::signal());
|
||||
break;
|
||||
|
||||
case SIGTERM:
|
||||
LOG_WARN("%s " YELLOW("SIGTERM received, exiting"), Tags::signal());
|
||||
break;
|
||||
|
||||
case SIGINT:
|
||||
LOG_WARN("%s " YELLOW("SIGINT received, exiting"), Tags::signal());
|
||||
break;
|
||||
return close();
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::App::close()
|
||||
{
|
||||
m_signals->stop();
|
||||
|
||||
if (m_console) {
|
||||
m_console->stop();
|
||||
}
|
||||
m_signals.reset();
|
||||
m_console.reset();
|
||||
|
||||
m_controller->stop();
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -60,9 +63,9 @@ private:
|
|||
bool background(int &rc);
|
||||
void close();
|
||||
|
||||
Console *m_console = nullptr;
|
||||
Controller *m_controller = nullptr;
|
||||
Signals *m_signals = nullptr;
|
||||
std::shared_ptr<Console> m_console;
|
||||
std::shared_ptr<Controller> m_controller;
|
||||
std::shared_ptr<Signals> m_signals;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 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,8 +36,6 @@
|
|||
|
||||
bool xmrig::App::background(int &rc)
|
||||
{
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (!m_controller->isBackground()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -160,11 +160,11 @@ static void print_threads(Config *config)
|
|||
static void print_commands(Config *)
|
||||
{
|
||||
if (Log::isColors()) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG(WHITE_BOLD_S "h") WHITE_BOLD("ashrate, ")
|
||||
MAGENTA_BG(WHITE_BOLD_S "p") WHITE_BOLD("ause, ")
|
||||
MAGENTA_BG(WHITE_BOLD_S "r") WHITE_BOLD("esume, ")
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG_BOLD("h") WHITE_BOLD("ashrate, ")
|
||||
MAGENTA_BG_BOLD("p") WHITE_BOLD("ause, ")
|
||||
MAGENTA_BG_BOLD("r") WHITE_BOLD("esume, ")
|
||||
WHITE_BOLD("re") MAGENTA_BG(WHITE_BOLD_S "s") WHITE_BOLD("ults, ")
|
||||
MAGENTA_BG(WHITE_BOLD_S "c") WHITE_BOLD("onnection")
|
||||
MAGENTA_BG_BOLD("c") WHITE_BOLD("onnection")
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
52
src/backend/common/GpuWorker.cpp
Normal file
52
src/backend/common/GpuWorker.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/common/GpuWorker.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
xmrig::GpuWorker::GpuWorker(size_t id, int64_t affinity, int priority, uint32_t deviceIndex) : Worker(id, affinity, priority),
|
||||
m_deviceIndex(deviceIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::GpuWorker::storeStats()
|
||||
{
|
||||
// Get index which is unused now
|
||||
const uint32_t index = m_index.load(std::memory_order_relaxed) ^ 1;
|
||||
|
||||
// Fill in the data for that index
|
||||
m_hashCount[index] = m_count;
|
||||
m_timestamp[index] = Chrono::steadyMSecs();
|
||||
|
||||
// Switch to that index
|
||||
// All data will be in memory by the time it completes thanks to std::memory_order_seq_cst
|
||||
m_index.fetch_xor(1, std::memory_order_seq_cst);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::GpuWorker::hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const
|
||||
{
|
||||
const uint32_t index = m_index.load(std::memory_order_relaxed);
|
||||
|
||||
rawHashes = m_hashrateData.interpolate(timeStamp);
|
||||
hashCount = m_hashCount[index];
|
||||
timeStamp = m_timestamp[index];
|
||||
}
|
58
src/backend/common/GpuWorker.h
Normal file
58
src/backend/common/GpuWorker.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_GPUWORKER_H
|
||||
#define XMRIG_GPUWORKER_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
||||
#include "backend/common/HashrateInterpolator.h"
|
||||
#include "backend/common/Worker.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class GpuWorker : public Worker
|
||||
{
|
||||
public:
|
||||
GpuWorker(size_t id, int64_t affinity, int priority, uint32_t m_deviceIndex);
|
||||
|
||||
protected:
|
||||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline uint32_t deviceIndex() const { return m_deviceIndex; }
|
||||
|
||||
void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const override;
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
|
||||
const uint32_t m_deviceIndex;
|
||||
HashrateInterpolator m_hashrateData;
|
||||
std::atomic<uint32_t> m_index = {};
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_GPUWORKER_H */
|
|
@ -1,12 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,7 +19,6 @@
|
|||
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <memory.h>
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -75,72 +69,6 @@ xmrig::Hashrate::~Hashrate()
|
|||
}
|
||||
|
||||
|
||||
double xmrig::Hashrate::calc(size_t ms) const
|
||||
{
|
||||
const double data = calc(0, ms);
|
||||
return std::isnormal(data) ? data : 0.0;
|
||||
}
|
||||
|
||||
|
||||
double xmrig::Hashrate::calc(size_t threadId, size_t ms) const
|
||||
{
|
||||
assert(threadId < m_threads);
|
||||
if (threadId >= m_threads) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
uint64_t earliestHashCount = 0;
|
||||
uint64_t earliestStamp = 0;
|
||||
bool haveFullSet = false;
|
||||
|
||||
const uint64_t timeStampLimit = xmrig::Chrono::steadyMSecs() - ms;
|
||||
uint64_t* timestamps = m_timestamps[threadId];
|
||||
uint64_t* counts = m_counts[threadId];
|
||||
|
||||
const size_t idx_start = (m_top[threadId] - 1) & kBucketMask;
|
||||
size_t idx = idx_start;
|
||||
|
||||
uint64_t lastestStamp = timestamps[idx];
|
||||
uint64_t lastestHashCnt = counts[idx];
|
||||
|
||||
do {
|
||||
if (timestamps[idx] < timeStampLimit) {
|
||||
haveFullSet = (timestamps[idx] != 0);
|
||||
if (idx != idx_start) {
|
||||
idx = (idx + 1) & kBucketMask;
|
||||
earliestStamp = timestamps[idx];
|
||||
earliestHashCount = counts[idx];
|
||||
}
|
||||
break;
|
||||
}
|
||||
idx = (idx - 1) & kBucketMask;
|
||||
} while (idx != idx_start);
|
||||
|
||||
if (!haveFullSet || earliestStamp == 0 || lastestStamp == 0) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
if (lastestStamp - earliestStamp == 0) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
const auto hashes = static_cast<double>(lastestHashCnt - earliestHashCount);
|
||||
const auto time = static_cast<double>(lastestStamp - earliestStamp) / 1000.0;
|
||||
|
||||
return hashes / time;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Hashrate::add(size_t threadId, uint64_t count, uint64_t timestamp)
|
||||
{
|
||||
const size_t top = m_top[threadId];
|
||||
m_counts[threadId][top] = count;
|
||||
m_timestamps[threadId][top] = timestamp;
|
||||
|
||||
m_top[threadId] = (top + 1) & kBucketMask;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::Hashrate::format(double h, char *buf, size_t size)
|
||||
{
|
||||
return ::format(h, buf, size);
|
||||
|
@ -174,10 +102,69 @@ rapidjson::Value xmrig::Hashrate::toJSON(size_t threadId, rapidjson::Document &d
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value out(kArrayType);
|
||||
out.PushBack(normalize(calc(threadId + 1, ShortInterval)), allocator);
|
||||
out.PushBack(normalize(calc(threadId + 1, MediumInterval)), allocator);
|
||||
out.PushBack(normalize(calc(threadId + 1, LargeInterval)), allocator);
|
||||
out.PushBack(normalize(calc(threadId, ShortInterval)), allocator);
|
||||
out.PushBack(normalize(calc(threadId, MediumInterval)), allocator);
|
||||
out.PushBack(normalize(calc(threadId, LargeInterval)), allocator);
|
||||
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
double xmrig::Hashrate::hashrate(size_t index, size_t ms) const
|
||||
{
|
||||
assert(index < m_threads);
|
||||
if (index >= m_threads) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
uint64_t earliestHashCount = 0;
|
||||
uint64_t earliestStamp = 0;
|
||||
bool haveFullSet = false;
|
||||
|
||||
const uint64_t timeStampLimit = xmrig::Chrono::steadyMSecs() - ms;
|
||||
uint64_t* timestamps = m_timestamps[index];
|
||||
uint64_t* counts = m_counts[index];
|
||||
|
||||
const size_t idx_start = (m_top[index] - 1) & kBucketMask;
|
||||
size_t idx = idx_start;
|
||||
|
||||
uint64_t lastestStamp = timestamps[idx];
|
||||
uint64_t lastestHashCnt = counts[idx];
|
||||
|
||||
do {
|
||||
if (timestamps[idx] < timeStampLimit) {
|
||||
haveFullSet = (timestamps[idx] != 0);
|
||||
if (idx != idx_start) {
|
||||
idx = (idx + 1) & kBucketMask;
|
||||
earliestStamp = timestamps[idx];
|
||||
earliestHashCount = counts[idx];
|
||||
}
|
||||
break;
|
||||
}
|
||||
idx = (idx - 1) & kBucketMask;
|
||||
} while (idx != idx_start);
|
||||
|
||||
if (!haveFullSet || earliestStamp == 0 || lastestStamp == 0) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
if (lastestStamp - earliestStamp == 0) {
|
||||
return nan("");
|
||||
}
|
||||
|
||||
const auto hashes = static_cast<double>(lastestHashCnt - earliestHashCount);
|
||||
const auto time = static_cast<double>(lastestStamp - earliestStamp) / 1000.0;
|
||||
|
||||
return hashes / time;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Hashrate::addData(size_t index, uint64_t count, uint64_t timestamp)
|
||||
{
|
||||
const size_t top = m_top[index];
|
||||
m_counts[index][top] = count;
|
||||
m_timestamps[index][top] = timestamp;
|
||||
|
||||
m_top[index] = (top + 1) & kBucketMask;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,6 +21,7 @@
|
|||
#define XMRIG_HASHRATE_H
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -42,7 +38,7 @@ class Hashrate
|
|||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Hashrate)
|
||||
|
||||
enum Intervals {
|
||||
enum Intervals : size_t {
|
||||
ShortInterval = 10000,
|
||||
MediumInterval = 60000,
|
||||
LargeInterval = 900000
|
||||
|
@ -50,11 +46,12 @@ public:
|
|||
|
||||
Hashrate(size_t threads);
|
||||
~Hashrate();
|
||||
double calc(size_t ms) const;
|
||||
double calc(size_t threadId, size_t ms) const;
|
||||
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
||||
|
||||
inline size_t threads() const { return m_threads; }
|
||||
inline double calc(size_t ms) const { const double data = hashrate(0U, ms); return std::isnormal(data) ? data : 0.0; }
|
||||
inline double calc(size_t threadId, size_t ms) const { return hashrate(threadId + 1, ms); }
|
||||
inline size_t threads() const { return m_threads > 0U ? m_threads - 1U : 0U; }
|
||||
inline void add(size_t threadId, uint64_t count, uint64_t timestamp) { addData(threadId + 1U, count, timestamp); }
|
||||
inline void add(uint64_t count, uint64_t timestamp) { addData(0U, count, timestamp); }
|
||||
|
||||
static const char *format(double h, char *buf, size_t size);
|
||||
static rapidjson::Value normalize(double d);
|
||||
|
@ -65,6 +62,9 @@ public:
|
|||
# endif
|
||||
|
||||
private:
|
||||
double hashrate(size_t index, size_t ms) const;
|
||||
void addData(size_t index, uint64_t count, uint64_t timestamp);
|
||||
|
||||
constexpr static size_t kBucketSize = 2 << 11;
|
||||
constexpr static size_t kBucketMask = kBucketSize - 1;
|
||||
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,7 +19,6 @@
|
|||
|
||||
#include "backend/common/Worker.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
|
||||
|
||||
|
@ -39,27 +31,3 @@ xmrig::Worker::Worker(size_t id, int64_t affinity, int priority) :
|
|||
Platform::trySetThreadAffinity(affinity);
|
||||
Platform::setThreadPriority(priority);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Worker::storeStats()
|
||||
{
|
||||
// Get index which is unused now
|
||||
const uint32_t index = m_index.load(std::memory_order_relaxed) ^ 1;
|
||||
|
||||
// Fill in the data for that index
|
||||
m_hashCount[index] = m_count;
|
||||
m_timestamp[index] = Chrono::steadyMSecs();
|
||||
|
||||
// Switch to that index
|
||||
// All data will be in memory by the time it completes thanks to std::memory_order_seq_cst
|
||||
m_index.fetch_xor(1, std::memory_order_seq_cst);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Worker::getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const
|
||||
{
|
||||
const uint32_t index = m_index.load(std::memory_order_relaxed);
|
||||
|
||||
hashCount = m_hashCount[index];
|
||||
timeStamp = m_timestamp[index];
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -27,9 +20,6 @@
|
|||
#define XMRIG_WORKER_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
|
||||
|
||||
|
@ -41,23 +31,17 @@ class Worker : public IWorker
|
|||
public:
|
||||
Worker(size_t id, int64_t affinity, int priority);
|
||||
|
||||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t rawHashes() const override { return m_count; }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
void getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const override;
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
inline int64_t affinity() const { return m_affinity; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint32_t node() const { return m_node; }
|
||||
|
||||
uint64_t m_count = 0;
|
||||
|
||||
private:
|
||||
const int64_t m_affinity;
|
||||
const size_t m_id;
|
||||
std::atomic<uint32_t> m_index = {};
|
||||
uint32_t m_node = 0;
|
||||
uint64_t m_count = 0;
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,16 +17,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/cpu/CpuWorker.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "core/Miner.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
|
@ -59,7 +49,6 @@ class WorkersPrivate
|
|||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(WorkersPrivate)
|
||||
|
||||
|
||||
WorkersPrivate() = default;
|
||||
~WorkersPrivate() = default;
|
||||
|
||||
|
@ -87,20 +76,6 @@ xmrig::Workers<T>::~Workers()
|
|||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
static void getHashrateData(xmrig::IWorker* worker, uint64_t& hashCount, uint64_t& timeStamp)
|
||||
{
|
||||
worker->getHashrateData(hashCount, timeStamp);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void getHashrateData<xmrig::CpuLaunchData>(xmrig::IWorker* worker, uint64_t& hashCount, uint64_t&)
|
||||
{
|
||||
hashCount = worker->rawHashes();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
bool xmrig::Workers<T>::tick(uint64_t)
|
||||
{
|
||||
|
@ -111,33 +86,32 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
uint64_t ts = Chrono::steadyMSecs();
|
||||
bool totalAvailable = true;
|
||||
uint64_t totalHashCount = 0;
|
||||
uint64_t hashCount = 0;
|
||||
uint64_t rawHashes = 0;
|
||||
|
||||
for (Thread<T> *handle : m_workers) {
|
||||
IWorker *worker = handle->worker();
|
||||
if (worker) {
|
||||
uint64_t hashCount;
|
||||
getHashrateData<T>(worker, hashCount, ts);
|
||||
d_ptr->hashrate->add(handle->id() + 1, hashCount, ts);
|
||||
worker->hashrateData(hashCount, ts, rawHashes);
|
||||
d_ptr->hashrate->add(handle->id(), hashCount, ts);
|
||||
|
||||
const uint64_t n = worker->rawHashes();
|
||||
if (n == 0) {
|
||||
if (rawHashes == 0) {
|
||||
totalAvailable = false;
|
||||
}
|
||||
totalHashCount += n;
|
||||
|
||||
totalHashCount += rawHashes;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalAvailable) {
|
||||
d_ptr->hashrate->add(0, totalHashCount, Chrono::steadyMSecs());
|
||||
d_ptr->hashrate->add(totalHashCount, Chrono::steadyMSecs());
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (d_ptr->benchmark && d_ptr->benchmark->finish(totalHashCount)) {
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
|
||||
return !d_ptr->benchmark || !d_ptr->benchmark->finish(totalHashCount);
|
||||
# else
|
||||
return true;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,14 +132,19 @@ void xmrig::Workers<T>::setBackend(IBackend *backend)
|
|||
template<class T>
|
||||
void xmrig::Workers<T>::stop()
|
||||
{
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::stop(T::backend());
|
||||
# endif
|
||||
|
||||
for (Thread<T> *worker : m_workers) {
|
||||
delete worker;
|
||||
}
|
||||
|
||||
m_workers.clear();
|
||||
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::touch(T::backend());
|
||||
# endif
|
||||
|
||||
d_ptr->hashrate.reset();
|
||||
}
|
||||
|
@ -226,7 +205,10 @@ void xmrig::Workers<T>::start(const std::vector<T> &data, bool sleep)
|
|||
}
|
||||
|
||||
d_ptr->hashrate = std::make_shared<Hashrate>(m_workers.size());
|
||||
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::touch(T::backend());
|
||||
# endif
|
||||
|
||||
for (auto worker : m_workers) {
|
||||
worker->start(Workers<T>::onReady);
|
||||
|
@ -247,6 +229,7 @@ namespace xmrig {
|
|||
template<>
|
||||
xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle)
|
||||
{
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
switch (handle->config().intensity) {
|
||||
case 1:
|
||||
return new CpuWorker<1>(handle->id(), handle->config());
|
||||
|
@ -265,6 +248,11 @@ xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *han
|
|||
}
|
||||
|
||||
return nullptr;
|
||||
# else
|
||||
assert(handle->config().intensity == 1);
|
||||
|
||||
return new CpuWorker<1>(handle->id(), handle->config());
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -44,10 +37,9 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
class Benchmark;
|
||||
class Hashrate;
|
||||
class WorkersPrivate;
|
||||
class Job;
|
||||
class Benchmark;
|
||||
|
||||
|
||||
template<class T>
|
||||
|
@ -63,7 +55,7 @@ public:
|
|||
|
||||
bool tick(uint64_t ticks);
|
||||
const Hashrate *hashrate() const;
|
||||
void jobEarlyNotification(const Job&);
|
||||
void jobEarlyNotification(const Job &job);
|
||||
void setBackend(IBackend *backend);
|
||||
void stop();
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
set(HEADERS_BACKEND_COMMON
|
||||
src/backend/common/Hashrate.h
|
||||
src/backend/common/HashrateInterpolator.h
|
||||
src/backend/common/Tags.h
|
||||
src/backend/common/interfaces/IBackend.h
|
||||
src/backend/common/interfaces/IRxListener.h
|
||||
|
@ -16,7 +15,6 @@ set(HEADERS_BACKEND_COMMON
|
|||
|
||||
set(SOURCES_BACKEND_COMMON
|
||||
src/backend/common/Hashrate.cpp
|
||||
src/backend/common/HashrateInterpolator.cpp
|
||||
src/backend/common/Threads.cpp
|
||||
src/backend/common/Worker.cpp
|
||||
src/backend/common/Workers.cpp
|
||||
|
@ -35,3 +33,16 @@ if (WITH_RANDOMX AND WITH_BENCHMARK)
|
|||
src/backend/common/benchmark/BenchState.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if (WITH_OPENCL OR WITH_CUDA)
|
||||
list(APPEND HEADERS_BACKEND_COMMON
|
||||
src/backend/common/HashrateInterpolator.h
|
||||
src/backend/common/GpuWorker.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_COMMON
|
||||
src/backend/common/HashrateInterpolator.cpp
|
||||
src/backend/common/GpuWorker.cpp
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,10 +20,11 @@
|
|||
#define XMRIG_IBACKEND_H
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -47,10 +42,14 @@ class String;
|
|||
class IBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IBackend)
|
||||
|
||||
IBackend() = default;
|
||||
virtual ~IBackend() = default;
|
||||
|
||||
virtual bool isEnabled() const = 0;
|
||||
virtual bool isEnabled(const Algorithm &algorithm) const = 0;
|
||||
virtual bool tick(uint64_t ticks) = 0;
|
||||
virtual const Hashrate *hashrate() const = 0;
|
||||
virtual const String &profileName() const = 0;
|
||||
virtual const String &type() const = 0;
|
||||
|
@ -61,7 +60,6 @@ public:
|
|||
virtual void setJob(const Job &job) = 0;
|
||||
virtual void start(IWorker *worker, bool ready) = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual bool tick(uint64_t ticks) = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
virtual rapidjson::Value toJSON(rapidjson::Document &doc) const = 0;
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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,6 +20,9 @@
|
|||
#define XMRIG_IMEMORYPOOL_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -38,6 +33,9 @@ namespace xmrig {
|
|||
class IMemoryPool
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IMemoryPool)
|
||||
|
||||
IMemoryPool() = default;
|
||||
virtual ~IMemoryPool() = default;
|
||||
|
||||
virtual bool isHugePages(uint32_t node) const = 0;
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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-2018 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2019 tevador <tevador@gmail.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,12 +21,18 @@
|
|||
#define XMRIG_IRXLISTENER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IRxListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IRxListener)
|
||||
|
||||
IRxListener() = default;
|
||||
virtual ~IRxListener() = default;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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-2018 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2019 tevador <tevador@gmail.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
#define XMRIG_IRXSTORAGE_H
|
||||
|
||||
|
||||
#include "crypto/rx/RxConfig.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "crypto/common/HugePagesInfo.h"
|
||||
#include "crypto/rx/RxConfig.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -43,6 +41,9 @@ class RxSeed;
|
|||
class IRxStorage
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IRxStorage)
|
||||
|
||||
IRxStorage() = default;
|
||||
virtual ~IRxStorage() = default;
|
||||
|
||||
virtual bool isAllocated() const = 0;
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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,8 +30,8 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
class VirtualMemory;
|
||||
class Job;
|
||||
class VirtualMemory;
|
||||
|
||||
|
||||
class IWorker
|
||||
|
@ -52,10 +46,9 @@ public:
|
|||
virtual const VirtualMemory *memory() const = 0;
|
||||
virtual size_t id() const = 0;
|
||||
virtual size_t intensity() const = 0;
|
||||
virtual uint64_t rawHashes() const = 0;
|
||||
virtual void getHashrateData(uint64_t&, uint64_t&) const = 0;
|
||||
virtual void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const = 0;
|
||||
virtual void jobEarlyNotification(const Job &job) = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void jobEarlyNotification(const Job&) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -266,6 +266,12 @@ bool xmrig::CpuBackend::isEnabled(const Algorithm &algorithm) const
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CpuBackend::tick(uint64_t ticks)
|
||||
{
|
||||
return d_ptr->workers.tick(ticks);
|
||||
}
|
||||
|
||||
|
||||
const xmrig::Hashrate *xmrig::CpuBackend::hashrate() const
|
||||
{
|
||||
return d_ptr->workers.hashrate();
|
||||
|
@ -316,9 +322,9 @@ void xmrig::CpuBackend::printHashrate(bool details)
|
|||
Log::print("| %8zu | %8" PRId64 " | %7s | %7s | %7s |",
|
||||
i,
|
||||
data.affinity,
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::ShortInterval), num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval), num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||
);
|
||||
|
||||
i++;
|
||||
|
@ -405,12 +411,6 @@ void xmrig::CpuBackend::stop()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CpuBackend::tick(uint64_t ticks)
|
||||
{
|
||||
return d_ptr->workers.tick(ticks);
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
|
||||
bool isEnabled() const override;
|
||||
bool isEnabled(const Algorithm &algorithm) const override;
|
||||
bool tick(uint64_t ticks) override;
|
||||
const Hashrate *hashrate() const override;
|
||||
const String &profileName() const override;
|
||||
const String &type() const override;
|
||||
|
@ -63,7 +64,6 @@ protected:
|
|||
void setJob(const Job &job) override;
|
||||
void start(IWorker *worker, bool ready) override;
|
||||
void stop() override;
|
||||
bool tick(uint64_t ticks) override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const override;
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -80,7 +73,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
|||
m_threads(data.threads),
|
||||
m_ctx()
|
||||
{
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, m_node);
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, node());
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,7 +93,7 @@ xmrig::CpuWorker<N>::~CpuWorker()
|
|||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::allocateRandomX_VM()
|
||||
{
|
||||
RxDataset *dataset = Rx::dataset(m_job.currentJob(), m_node);
|
||||
RxDataset *dataset = Rx::dataset(m_job.currentJob(), node());
|
||||
|
||||
while (dataset == nullptr) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
|
@ -109,13 +102,13 @@ void xmrig::CpuWorker<N>::allocateRandomX_VM()
|
|||
return;
|
||||
}
|
||||
|
||||
dataset = Rx::dataset(m_job.currentJob(), m_node);
|
||||
dataset = Rx::dataset(m_job.currentJob(), node());
|
||||
}
|
||||
|
||||
if (!m_vm) {
|
||||
// Try to allocate scratchpad from dataset's 1 GB huge pages, if normal huge pages are not available
|
||||
uint8_t* scratchpad = m_memory->isHugePages() ? m_memory->scratchpad() : dataset->tryAllocateScrathpad();
|
||||
m_vm = RxVm::create(dataset, scratchpad ? scratchpad : m_memory->scratchpad(), !m_hwAES, m_assembly, m_node);
|
||||
m_vm = RxVm::create(dataset, scratchpad ? scratchpad : m_memory->scratchpad(), !m_hwAES, m_assembly, node());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -189,6 +182,14 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::hashrateData(uint64_t &hashCount, uint64_t &, uint64_t &rawHashes) const
|
||||
{
|
||||
hashCount = m_count;
|
||||
rawHashes = m_count;
|
||||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::start()
|
||||
{
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -56,10 +49,12 @@ public:
|
|||
|
||||
protected:
|
||||
bool selfTest() override;
|
||||
void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const override;
|
||||
void start() override;
|
||||
|
||||
inline const VirtualMemory *memory() const override { return m_memory; }
|
||||
inline size_t intensity() const override { return N; }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
private:
|
||||
inline cn_hash_fun fn(const Algorithm &algorithm) const { return CnHash::fn(algorithm, m_av, m_assembly); }
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -409,9 +409,9 @@ void xmrig::CudaBackend::printHashrate(bool details)
|
|||
Log::print("| %8zu | %8" PRId64 " | %8s | %8s | %8s |" CYAN_BOLD(" #%u") YELLOW(" %s") GREEN(" %s"),
|
||||
i,
|
||||
data.thread.affinity(),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::ShortInterval) * scale, num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::MediumInterval) * scale, num + 16, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::LargeInterval) * scale, num + 16 * 2, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval) * scale, num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval) * scale, num + 16, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval) * scale, num + 16 * 2, sizeof num / 3),
|
||||
data.device.index(),
|
||||
data.device.topology().toString().data(),
|
||||
data.device.name().data()
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -69,10 +62,9 @@ static inline bool isReady() { return !Nonce::isPaused()
|
|||
|
||||
|
||||
xmrig::CudaWorker::CudaWorker(size_t id, const CudaLaunchData &data) :
|
||||
Worker(id, data.thread.affinity(), -1),
|
||||
GpuWorker(id, data.thread.affinity(), -1, data.device.index()),
|
||||
m_algorithm(data.algorithm),
|
||||
m_miner(data.miner),
|
||||
m_deviceIndex(data.device.index())
|
||||
m_miner(data.miner)
|
||||
{
|
||||
switch (m_algorithm.family()) {
|
||||
case Algorithm::RANDOM_X:
|
||||
|
@ -119,12 +111,6 @@ xmrig::CudaWorker::~CudaWorker()
|
|||
}
|
||||
|
||||
|
||||
uint64_t xmrig::CudaWorker::rawHashes() const
|
||||
{
|
||||
return m_hashrateData.interpolate(Chrono::steadyMSecs());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CudaWorker::jobEarlyNotification(const Job &job)
|
||||
{
|
||||
if (m_runner) {
|
||||
|
@ -213,5 +199,5 @@ void xmrig::CudaWorker::storeStats()
|
|||
const uint64_t timeStamp = Chrono::steadyMSecs();
|
||||
m_hashrateData.addDataPoint(m_count, timeStamp);
|
||||
|
||||
Worker::storeStats();
|
||||
GpuWorker::storeStats();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -27,8 +20,7 @@
|
|||
#define XMRIG_CUDAWORKER_H
|
||||
|
||||
|
||||
#include "backend/common/HashrateInterpolator.h"
|
||||
#include "backend/common/Worker.h"
|
||||
#include "backend/common/GpuWorker.h"
|
||||
#include "backend/common/WorkerJob.h"
|
||||
#include "backend/cuda/CudaLaunchData.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
@ -41,7 +33,7 @@ namespace xmrig {
|
|||
class ICudaRunner;
|
||||
|
||||
|
||||
class CudaWorker : public Worker
|
||||
class CudaWorker : public GpuWorker
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(CudaWorker)
|
||||
|
@ -50,8 +42,7 @@ public:
|
|||
|
||||
~CudaWorker() override;
|
||||
|
||||
uint64_t rawHashes() const override;
|
||||
void jobEarlyNotification(const Job&) override;
|
||||
void jobEarlyNotification(const Job &job) override;
|
||||
|
||||
static std::atomic<bool> ready;
|
||||
|
||||
|
@ -68,9 +59,6 @@ private:
|
|||
const Miner *m_miner;
|
||||
ICudaRunner *m_runner = nullptr;
|
||||
WorkerJob<1> m_job;
|
||||
uint32_t m_deviceIndex;
|
||||
|
||||
HashrateInterpolator m_hashrateData;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -385,9 +385,9 @@ void xmrig::OclBackend::printHashrate(bool details)
|
|||
Log::print("| %8zu | %8" PRId64 " | %8s | %8s | %8s |" CYAN_BOLD(" #%u") YELLOW(" %s") " %s",
|
||||
i,
|
||||
data.affinity,
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::ShortInterval) * scale, num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::MediumInterval) * scale, num + 16, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::LargeInterval) * scale, num + 16 * 2, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval) * scale, num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval) * scale, num + 16, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval) * scale, num + 16 * 2, sizeof num / 3),
|
||||
data.device.index(),
|
||||
data.device.topology().toString().data(),
|
||||
data.device.printableName().data()
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -73,11 +66,10 @@ static inline void printError(size_t id, const char *error)
|
|||
|
||||
|
||||
xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) :
|
||||
Worker(id, data.affinity, -1),
|
||||
GpuWorker(id, data.affinity, -1, data.device.index()),
|
||||
m_algorithm(data.algorithm),
|
||||
m_miner(data.miner),
|
||||
m_sharedData(OclSharedState::get(data.device.index())),
|
||||
m_deviceIndex(data.device.index())
|
||||
m_sharedData(OclSharedState::get(data.device.index()))
|
||||
{
|
||||
switch (m_algorithm.family()) {
|
||||
case Algorithm::RANDOM_X:
|
||||
|
@ -137,12 +129,6 @@ xmrig::OclWorker::~OclWorker()
|
|||
}
|
||||
|
||||
|
||||
uint64_t xmrig::OclWorker::rawHashes() const
|
||||
{
|
||||
return m_hashrateData.interpolate(Chrono::steadyMSecs());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclWorker::jobEarlyNotification(const Job &job)
|
||||
{
|
||||
if (m_runner) {
|
||||
|
@ -180,7 +166,7 @@ void xmrig::OclWorker::start()
|
|||
break;
|
||||
}
|
||||
|
||||
m_sharedData.resumeDelay(m_id);
|
||||
m_sharedData.resumeDelay(id());
|
||||
|
||||
if (!consumeJob()) {
|
||||
return;
|
||||
|
@ -188,7 +174,7 @@ void xmrig::OclWorker::start()
|
|||
}
|
||||
|
||||
while (!Nonce::isOutdated(Nonce::OPENCL, m_job.sequence())) {
|
||||
m_sharedData.adjustDelay(m_id);
|
||||
m_sharedData.adjustDelay(id());
|
||||
|
||||
const uint64_t t = Chrono::steadyMSecs();
|
||||
|
||||
|
@ -254,5 +240,5 @@ void xmrig::OclWorker::storeStats(uint64_t t)
|
|||
|
||||
m_sharedData.setRunTime(timeStamp - t);
|
||||
|
||||
Worker::storeStats();
|
||||
GpuWorker::storeStats();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -27,8 +20,7 @@
|
|||
#define XMRIG_OCLWORKER_H
|
||||
|
||||
|
||||
#include "backend/common/HashrateInterpolator.h"
|
||||
#include "backend/common/Worker.h"
|
||||
#include "backend/common/GpuWorker.h"
|
||||
#include "backend/common/WorkerJob.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
@ -42,7 +34,7 @@ class IOclRunner;
|
|||
class Job;
|
||||
|
||||
|
||||
class OclWorker : public Worker
|
||||
class OclWorker : public GpuWorker
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclWorker)
|
||||
|
@ -51,8 +43,7 @@ public:
|
|||
|
||||
~OclWorker() override;
|
||||
|
||||
uint64_t rawHashes() const override;
|
||||
void jobEarlyNotification(const Job&) override;
|
||||
void jobEarlyNotification(const Job &job) override;
|
||||
|
||||
static std::atomic<bool> ready;
|
||||
|
||||
|
@ -70,9 +61,6 @@ private:
|
|||
IOclRunner *m_runner = nullptr;
|
||||
OclSharedData &m_sharedData;
|
||||
WorkerJob<1> m_job;
|
||||
uint32_t m_deviceIndex;
|
||||
|
||||
HashrateInterpolator m_hashrateData;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "base/io/Env.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/kernel/Base.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "version.h"
|
||||
|
@ -228,7 +228,7 @@ void xmrig::Api::genId(const String &id)
|
|||
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, (sizeof(APP_KIND) - 1));
|
||||
|
||||
keccak(input, inSize, hash);
|
||||
Buffer::toHex(hash, 8, m_id);
|
||||
Cvt::toHex(m_id, sizeof(m_id), hash, 8);
|
||||
|
||||
delete [] input;
|
||||
break;
|
||||
|
|
|
@ -22,6 +22,7 @@ set(HEADERS_BASE
|
|||
src/base/kernel/config/BaseConfig.h
|
||||
src/base/kernel/config/BaseTransform.h
|
||||
src/base/kernel/config/Title.h
|
||||
src/base/kernel/constants.h
|
||||
src/base/kernel/Entry.h
|
||||
src/base/kernel/interfaces/IAsyncListener.h
|
||||
src/base/kernel/interfaces/IBaseListener.h
|
||||
|
@ -66,6 +67,7 @@ set(HEADERS_BASE
|
|||
src/base/tools/Baton.h
|
||||
src/base/tools/Buffer.h
|
||||
src/base/tools/Chrono.h
|
||||
src/base/tools/Cvt.h
|
||||
src/base/tools/Handle.h
|
||||
src/base/tools/String.h
|
||||
src/base/tools/Timer.h
|
||||
|
@ -113,7 +115,7 @@ set(SOURCES_BASE
|
|||
src/base/net/tools/LineReader.cpp
|
||||
src/base/net/tools/NetBuffer.cpp
|
||||
src/base/tools/Arguments.cpp
|
||||
src/base/tools/Buffer.cpp
|
||||
src/base/tools/Cvt.cpp
|
||||
src/base/tools/String.cpp
|
||||
src/base/tools/Timer.cpp
|
||||
)
|
||||
|
@ -230,13 +232,6 @@ if (WITH_KAWPOW)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (WITH_PROFILING)
|
||||
add_definitions(/DXMRIG_FEATURE_PROFILING)
|
||||
|
||||
list(APPEND HEADERS_BASE src/base/tools/Profiler.h)
|
||||
list(APPEND SOURCES_BASE src/base/tools/Profiler.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
if (WITH_RANDOMX AND WITH_BENCHMARK)
|
||||
add_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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,20 +44,9 @@ xmrig::Console::Console(IConsoleListener *listener)
|
|||
|
||||
xmrig::Console::~Console()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Console::stop()
|
||||
{
|
||||
if (!m_tty) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_tty_reset_mode();
|
||||
|
||||
Handle::close(m_tty);
|
||||
m_tty = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -29,7 +23,16 @@
|
|||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
using uv_buf_t = struct uv_buf_t;
|
||||
using uv_handle_t = struct uv_handle_s;
|
||||
using uv_stream_t = struct uv_stream_s;
|
||||
using uv_tty_t = struct uv_tty_s;
|
||||
|
||||
#ifdef XMRIG_OS_WIN
|
||||
using ssize_t = intptr_t;
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -46,8 +49,6 @@ public:
|
|||
Console(IConsoleListener *listener);
|
||||
~Console();
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
bool isSupported() const;
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -23,22 +17,29 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/io/Signals.h"
|
||||
#include "base/kernel/interfaces/ISignalListener.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/io/Signals.h"
|
||||
#include "base/tools/Handle.h"
|
||||
|
||||
|
||||
#ifdef SIGUSR1
|
||||
static const int signums[xmrig::Signals::kSignalsCount] = { SIGHUP, SIGINT, SIGTERM, SIGUSR1 };
|
||||
#else
|
||||
static const int signums[xmrig::Signals::kSignalsCount] = { SIGHUP, SIGINT, SIGTERM };
|
||||
#endif
|
||||
|
||||
|
||||
xmrig::Signals::Signals(ISignalListener *listener)
|
||||
: m_listener(listener)
|
||||
{
|
||||
# ifndef XMRIG_OS_WIN
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
# endif
|
||||
|
||||
for (size_t i = 0; i < kSignalsCount; ++i) {
|
||||
uv_signal_t *signal = new uv_signal_t;
|
||||
auto signal = new uv_signal_t;
|
||||
signal->data = this;
|
||||
|
||||
m_signals[i] = signal;
|
||||
|
@ -51,24 +52,37 @@ xmrig::Signals::Signals(ISignalListener *listener)
|
|||
|
||||
xmrig::Signals::~Signals()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Signals::stop()
|
||||
{
|
||||
if (!m_signals[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < kSignalsCount; ++i) {
|
||||
Handle::close(m_signals[i]);
|
||||
m_signals[i] = nullptr;
|
||||
for (auto signal : m_signals) {
|
||||
Handle::close(signal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Signals::onSignal(uv_signal_t *handle, int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGHUP:
|
||||
LOG_WARN("%s " YELLOW("SIGHUP received, exiting"), Tags::signal());
|
||||
break;
|
||||
|
||||
case SIGTERM:
|
||||
LOG_WARN("%s " YELLOW("SIGTERM received, exiting"), Tags::signal());
|
||||
break;
|
||||
|
||||
case SIGINT:
|
||||
LOG_WARN("%s " YELLOW("SIGINT received, exiting"), Tags::signal());
|
||||
break;
|
||||
|
||||
# ifdef SIGUSR1
|
||||
case SIGUSR1:
|
||||
LOG_V5("%s " WHITE_BOLD("SIGUSR1 received"), Tags::signal());
|
||||
break;
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
static_cast<Signals *>(handle->data)->m_listener->onSignal(signum);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,10 +20,14 @@
|
|||
#define XMRIG_SIGNALS_H
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
typedef struct uv_signal_s uv_signal_t;
|
||||
#include <csignal>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
using uv_signal_t = struct uv_signal_s;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -41,20 +39,24 @@ class ISignalListener;
|
|||
class Signals
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Signals)
|
||||
|
||||
# ifdef SIGUSR1
|
||||
constexpr static const size_t kSignalsCount = 4;
|
||||
# else
|
||||
constexpr static const size_t kSignalsCount = 3;
|
||||
# endif
|
||||
|
||||
Signals(ISignalListener *listener);
|
||||
~Signals();
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
void close(int signum);
|
||||
|
||||
static void onSignal(uv_signal_t *handle, int signum);
|
||||
|
||||
ISignalListener *m_listener;
|
||||
uv_signal_t *m_signals[kSignalsCount];
|
||||
uv_signal_t *m_signals[kSignalsCount]{};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -29,6 +23,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <istream>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -119,6 +114,21 @@ const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const
|
|||
}
|
||||
|
||||
|
||||
double xmrig::Json::getDouble(const rapidjson::Value &obj, const char *key, double defaultValue)
|
||||
{
|
||||
if (isEmpty(obj)) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && (i->value.IsDouble() || i->value.IsLosslessDouble())) {
|
||||
return i->value.GetDouble();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
|
||||
{
|
||||
if (isEmpty(obj)) {
|
||||
|
@ -149,6 +159,25 @@ int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int6
|
|||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Json::getString(const rapidjson::Value &obj, const char *key, size_t maxSize)
|
||||
{
|
||||
if (isEmpty(obj)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i == obj.MemberEnd() || !i->value.IsString()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (maxSize == 0 || i->value.GetStringLength() <= maxSize) {
|
||||
return i->value.GetString();
|
||||
}
|
||||
|
||||
return { i->value.GetString(), maxSize };
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
|
||||
{
|
||||
if (isEmpty(obj)) {
|
||||
|
@ -222,6 +251,11 @@ bool xmrig::Json::convertOffset(std::istream &ifs, size_t offset, size_t &line,
|
|||
}
|
||||
|
||||
|
||||
xmrig::JsonReader::JsonReader() :
|
||||
m_obj(kNullValue)
|
||||
{}
|
||||
|
||||
|
||||
bool xmrig::JsonReader::isEmpty() const
|
||||
{
|
||||
return Json::isEmpty(m_obj);
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,13 +20,10 @@
|
|||
#define XMRIG_JSON_H
|
||||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -47,8 +38,10 @@ public:
|
|||
static const rapidjson::Value &getArray(const rapidjson::Value &obj, const char *key);
|
||||
static const rapidjson::Value &getObject(const rapidjson::Value &obj, const char *key);
|
||||
static const rapidjson::Value &getValue(const rapidjson::Value &obj, const char *key);
|
||||
static double getDouble(const rapidjson::Value &obj, const char *key, double defaultValue = 0);
|
||||
static int getInt(const rapidjson::Value &obj, const char *key, int defaultValue = 0);
|
||||
static int64_t getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue = 0);
|
||||
static String getString(const rapidjson::Value &obj, const char *key, size_t maxSize);
|
||||
static uint64_t getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue = 0);
|
||||
static unsigned getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue = 0);
|
||||
|
||||
|
@ -66,6 +59,7 @@ private:
|
|||
class JsonReader : public IJsonReader
|
||||
{
|
||||
public:
|
||||
JsonReader();
|
||||
inline JsonReader(const rapidjson::Value &obj) : m_obj(obj) {}
|
||||
|
||||
inline bool getBool(const char *key, bool defaultValue = false) const override { return Json::getBool(m_obj, key, defaultValue); }
|
||||
|
@ -73,8 +67,11 @@ public:
|
|||
inline const rapidjson::Value &getArray(const char *key) const override { return Json::getArray(m_obj, key); }
|
||||
inline const rapidjson::Value &getObject(const char *key) const override { return Json::getObject(m_obj, key); }
|
||||
inline const rapidjson::Value &getValue(const char *key) const override { return Json::getValue(m_obj, key); }
|
||||
inline const rapidjson::Value &object() const override { return m_obj; }
|
||||
inline double getDouble(const char *key, double defaultValue = 0) const override { return Json::getDouble(m_obj, key, defaultValue); }
|
||||
inline int getInt(const char *key, int defaultValue = 0) const override { return Json::getInt(m_obj, key, defaultValue); }
|
||||
inline int64_t getInt64(const char *key, int64_t defaultValue = 0) const override { return Json::getInt64(m_obj, key, defaultValue); }
|
||||
inline String getString(const char *key, size_t maxSize) const override { return Json::getString(m_obj, key, maxSize); }
|
||||
inline uint64_t getUint64(const char *key, uint64_t defaultValue = 0) const override { return Json::getUint64(m_obj, key, defaultValue); }
|
||||
inline unsigned getUint(const char *key, unsigned defaultValue = 0) const override { return Json::getUint(m_obj, key, defaultValue); }
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -181,6 +175,28 @@ const rapidjson::Value &xmrig::JsonChain::getValue(const char *key) const
|
|||
}
|
||||
|
||||
|
||||
|
||||
const rapidjson::Value &xmrig::JsonChain::object() const
|
||||
{
|
||||
assert(false);
|
||||
|
||||
return m_chain.back();
|
||||
}
|
||||
|
||||
|
||||
double xmrig::JsonChain::getDouble(const char *key, double defaultValue) const
|
||||
{
|
||||
for (auto it = m_chain.rbegin(); it != m_chain.rend(); ++it) {
|
||||
auto i = it->FindMember(key);
|
||||
if (i != it->MemberEnd() && (i->value.IsDouble() || i->value.IsLosslessDouble())) {
|
||||
return i->value.GetDouble();
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
int xmrig::JsonChain::getInt(const char *key, int defaultValue) const
|
||||
{
|
||||
for (auto it = m_chain.rbegin(); it != m_chain.rend(); ++it) {
|
||||
|
@ -207,6 +223,24 @@ int64_t xmrig::JsonChain::getInt64(const char *key, int64_t defaultValue) const
|
|||
}
|
||||
|
||||
|
||||
|
||||
xmrig::String xmrig::JsonChain::getString(const char *key, size_t maxSize) const
|
||||
{
|
||||
for (auto it = m_chain.rbegin(); it != m_chain.rend(); ++it) {
|
||||
auto i = it->FindMember(key);
|
||||
if (i != it->MemberEnd() && i->value.IsString()) {
|
||||
if (maxSize == 0 || i->value.GetStringLength() <= maxSize) {
|
||||
return i->value.GetString();
|
||||
}
|
||||
|
||||
return { i->value.GetString(), maxSize };
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::JsonChain::getUint64(const char *key, uint64_t defaultValue) const
|
||||
{
|
||||
for (auto it = m_chain.rbegin(); it != m_chain.rend(); ++it) {
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -59,8 +53,11 @@ protected:
|
|||
const rapidjson::Value &getArray(const char *key) const override;
|
||||
const rapidjson::Value &getObject(const char *key) const override;
|
||||
const rapidjson::Value &getValue(const char *key) const override;
|
||||
const rapidjson::Value &object() const override;
|
||||
double getDouble(const char *key, double defaultValue = 0) const override;
|
||||
int getInt(const char *key, int defaultValue = 0) const override;
|
||||
int64_t getInt64(const char *key, int64_t defaultValue = 0) const override;
|
||||
String getString(const char *key, size_t maxSize) const override;
|
||||
uint64_t getUint64(const char *key, uint64_t defaultValue = 0) const override;
|
||||
unsigned getUint(const char *key, unsigned defaultValue = 0) const override;
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -30,16 +24,33 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *k2_0 = "2.0";
|
||||
static const char *kId = "id";
|
||||
static const char *kJsonRPC = "jsonrpc";
|
||||
static const char *kMethod = "method";
|
||||
const char *JsonRequest::k2_0 = "2.0";
|
||||
const char *JsonRequest::kId = "id";
|
||||
const char *JsonRequest::kJsonRPC = "jsonrpc";
|
||||
const char *JsonRequest::kMethod = "method";
|
||||
const char *JsonRequest::kOK = "OK";
|
||||
const char *JsonRequest::kParams = "params";
|
||||
const char *JsonRequest::kResult = "result";
|
||||
const char *JsonRequest::kStatus = "status";
|
||||
|
||||
const char *JsonRequest::kParseError = "parse error";
|
||||
const char *JsonRequest::kInvalidRequest = "invalid request";
|
||||
const char *JsonRequest::kMethodNotFound = "method not found";
|
||||
const char *JsonRequest::kInvalidParams = "invalid params";
|
||||
const char *JsonRequest::kInternalError = "internal error";
|
||||
|
||||
static uint64_t nextId = 0;
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
rapidjson::Document xmrig::JsonRequest::create(const char *method)
|
||||
{
|
||||
return create(++nextId, method);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Document xmrig::JsonRequest::create(int64_t id, const char *method)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
@ -54,7 +65,13 @@ rapidjson::Document xmrig::JsonRequest::create(int64_t id, const char *method)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms)
|
||||
uint64_t xmrig::JsonRequest::create(rapidjson::Document &doc, const char *method, rapidjson::Value ¶ms)
|
||||
{
|
||||
return create(doc, ++nextId, method, params);
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
@ -63,4 +80,6 @@ void xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char
|
|||
doc.AddMember(StringRef(kJsonRPC), StringRef(k2_0), allocator);
|
||||
doc.AddMember(StringRef(kMethod), StringRef(method), allocator);
|
||||
doc.AddMember(StringRef(kParams), params, allocator);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -35,10 +29,31 @@ namespace xmrig {
|
|||
class JsonRequest
|
||||
{
|
||||
public:
|
||||
static const char *k2_0;
|
||||
static const char *kId;
|
||||
static const char *kJsonRPC;
|
||||
static const char *kMethod;
|
||||
static const char *kOK;
|
||||
static const char *kParams;
|
||||
static const char *kResult;
|
||||
static const char *kStatus;
|
||||
|
||||
static const char *kParseError;
|
||||
static const char *kInvalidRequest;
|
||||
static const char *kMethodNotFound;
|
||||
static const char *kInvalidParams;
|
||||
static const char *kInternalError;
|
||||
|
||||
constexpr static int kParseErrorCode = -32700;
|
||||
constexpr static int kInvalidRequestCode = -32600;
|
||||
constexpr static int kMethodNotFoundCode = -32601;
|
||||
constexpr static int kInvalidParamsCode = -32602;
|
||||
constexpr static int kInternalErrorCode = -32603;
|
||||
|
||||
static rapidjson::Document create(const char *method);
|
||||
static rapidjson::Document create(int64_t id, const char *method);
|
||||
static void create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms);
|
||||
static uint64_t create(rapidjson::Document &doc, const char *method, rapidjson::Value ¶ms);
|
||||
static uint64_t create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -43,7 +37,7 @@ bool xmrig::Json::get(const char *fileName, rapidjson::Document &doc)
|
|||
rapidjson::IStreamWrapper isw(ifs);
|
||||
doc.ParseStream<rapidjson::kParseCommentsFlag | rapidjson::kParseTrailingCommasFlag>(isw);
|
||||
|
||||
return !doc.HasParseError() && doc.IsObject();
|
||||
return !doc.HasParseError() && (doc.IsObject() || doc.IsArray());
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +50,10 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
|||
|
||||
rapidjson::OStreamWrapper osw(ofs);
|
||||
rapidjson::PrettyWriter<rapidjson::OStreamWrapper> writer(osw);
|
||||
|
||||
# ifdef XMRIG_JSON_SINGLE_LINE_ARRAY
|
||||
writer.SetFormatOptions(rapidjson::kFormatSingleLineArray);
|
||||
# endif
|
||||
|
||||
doc.Accept(writer);
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -96,7 +90,7 @@ bool xmrig::Json::get(const char *fileName, rapidjson::Document &doc)
|
|||
IStreamWrapper isw(ifs);
|
||||
doc.ParseStream<kParseCommentsFlag | kParseTrailingCommasFlag>(isw);
|
||||
|
||||
return !doc.HasParseError() && doc.IsObject();
|
||||
return !doc.HasParseError() && (doc.IsObject() || doc.IsArray());
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +121,10 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
|||
|
||||
OStreamWrapper osw(ofs);
|
||||
PrettyWriter<OStreamWrapper> writer(osw);
|
||||
|
||||
# ifdef XMRIG_JSON_SINGLE_LINE_ARRAY
|
||||
writer.SetFormatOptions(kFormatSingleLineArray);
|
||||
# endif
|
||||
|
||||
doc.Accept(writer);
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -31,6 +25,7 @@
|
|||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
|
@ -76,7 +71,7 @@ public:
|
|||
|
||||
inline ~LogPrivate()
|
||||
{
|
||||
for (ILogBackend *backend : m_backends) {
|
||||
for (auto backend : m_backends) {
|
||||
delete backend;
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +91,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
timestamp(level, size, offset);
|
||||
const uint64_t ts = timestamp(level, size, offset);
|
||||
color(level, size);
|
||||
|
||||
const int rc = vsnprintf(m_buf + size, sizeof (m_buf) - offset - 32, fmt, args);
|
||||
|
@ -114,9 +109,9 @@ public:
|
|||
}
|
||||
|
||||
if (!m_backends.empty()) {
|
||||
for (ILogBackend *backend : m_backends) {
|
||||
backend->print(level, m_buf, offset, size, true);
|
||||
backend->print(level, txt.c_str(), offset ? (offset - 11) : 0, txt.size(), false);
|
||||
for (auto backend : m_backends) {
|
||||
backend->print(ts, level, m_buf, offset, size, true);
|
||||
backend->print(ts, level, txt.c_str(), offset ? (offset - 11) : 0, txt.size(), false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -127,13 +122,14 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
inline void timestamp(Log::Level level, size_t &size, size_t &offset)
|
||||
inline uint64_t timestamp(Log::Level level, size_t &size, size_t &offset)
|
||||
{
|
||||
const uint64_t ms = Chrono::currentMSecsSinceEpoch();
|
||||
|
||||
if (level == Log::NONE) {
|
||||
return;
|
||||
return ms;
|
||||
}
|
||||
|
||||
const uint64_t ms = Chrono::currentMSecsSinceEpoch();
|
||||
time_t now = ms / 1000;
|
||||
tm stime{};
|
||||
|
||||
|
@ -156,6 +152,8 @@ private:
|
|||
if (rc > 0) {
|
||||
size = offset = static_cast<size_t>(rc);
|
||||
}
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +195,7 @@ private:
|
|||
|
||||
bool Log::m_background = false;
|
||||
bool Log::m_colors = true;
|
||||
LogPrivate *Log::d = new LogPrivate();
|
||||
LogPrivate *Log::d = nullptr;
|
||||
uint32_t Log::m_verbose = 0;
|
||||
|
||||
|
||||
|
@ -207,6 +205,8 @@ uint32_t Log::m_verbose = 0;
|
|||
|
||||
void xmrig::Log::add(ILogBackend *backend)
|
||||
{
|
||||
assert(d != nullptr);
|
||||
|
||||
if (d) {
|
||||
d->add(backend);
|
||||
}
|
||||
|
@ -220,6 +220,12 @@ void xmrig::Log::destroy()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Log::init()
|
||||
{
|
||||
d = new LogPrivate();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Log::print(const char *fmt, ...)
|
||||
{
|
||||
if (!d) {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -57,6 +51,7 @@ public:
|
|||
|
||||
static void add(ILogBackend *backend);
|
||||
static void destroy();
|
||||
static void init();
|
||||
static void print(const char *fmt, ...);
|
||||
static void print(Level level, const char *fmt, ...);
|
||||
|
||||
|
@ -71,9 +66,8 @@ public:
|
|||
private:
|
||||
static bool m_background;
|
||||
static bool m_colors;
|
||||
static uint32_t m_verbose;
|
||||
|
||||
static LogPrivate *d;
|
||||
static uint32_t m_verbose;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,14 +18,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
#include "base/io/log/backends/ConsoleLog.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/config/Title.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
xmrig::ConsoleLog::ConsoleLog(const Title &title)
|
||||
|
@ -75,7 +68,7 @@ xmrig::ConsoleLog::~ConsoleLog()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors)
|
||||
void xmrig::ConsoleLog::print(uint64_t, int, const char *line, size_t, size_t size, bool colors)
|
||||
{
|
||||
if (!m_tty || Log::isColors() != colors) {
|
||||
return;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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,7 +44,7 @@ public:
|
|||
~ConsoleLog() override;
|
||||
|
||||
protected:
|
||||
void print(int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
|
||||
private:
|
||||
bool isSupported() const;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -37,7 +31,7 @@ xmrig::FileLog::FileLog(const char *fileName) :
|
|||
}
|
||||
|
||||
|
||||
void xmrig::FileLog::print(int, const char *line, size_t, size_t size, bool colors)
|
||||
void xmrig::FileLog::print(uint64_t, int, const char *line, size_t, size_t size, bool colors)
|
||||
{
|
||||
if (!m_writer.isOpen() || colors) {
|
||||
return;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -40,7 +34,7 @@ public:
|
|||
FileLog(const char *fileName);
|
||||
|
||||
protected:
|
||||
void print(int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
|
||||
private:
|
||||
FileLogWriter m_writer;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -43,7 +37,7 @@ xmrig::SysLog::~SysLog()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::SysLog::print(int level, const char *line, size_t offset, size_t, bool colors)
|
||||
void xmrig::SysLog::print(uint64_t, int level, const char *line, size_t offset, size_t, bool colors)
|
||||
{
|
||||
if (colors) {
|
||||
return;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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,11 +30,13 @@ namespace xmrig {
|
|||
class SysLog : public ILogBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(SysLog)
|
||||
|
||||
SysLog();
|
||||
~SysLog() override;
|
||||
|
||||
protected:
|
||||
void print(int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ private:
|
|||
xmrig::Base::Base(Process *process)
|
||||
: d_ptr(new BasePrivate(process))
|
||||
{
|
||||
Log::init();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
31
src/base/kernel/constants.h
Normal file
31
src/base/kernel/constants.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CONSTANTS_H
|
||||
#define XMRIG_CONSTANTS_H
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
constexpr size_t XMRIG_NET_BUFFER_CHUNK_SIZE = 64 * 1024;
|
||||
constexpr size_t XMRIG_NET_BUFFER_INIT_CHUNKS = 4;
|
||||
|
||||
|
||||
#endif /* XMRIG_CONSTANTS_H */
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -27,6 +21,8 @@
|
|||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -35,6 +31,9 @@ namespace xmrig {
|
|||
class IJsonReader
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IJsonReader)
|
||||
|
||||
IJsonReader() = default;
|
||||
virtual ~IJsonReader() = default;
|
||||
|
||||
virtual bool getBool(const char *key, bool defaultValue = false) const = 0;
|
||||
|
@ -43,8 +42,11 @@ public:
|
|||
virtual const rapidjson::Value &getArray(const char *key) const = 0;
|
||||
virtual const rapidjson::Value &getObject(const char *key) const = 0;
|
||||
virtual const rapidjson::Value &getValue(const char *key) const = 0;
|
||||
virtual const rapidjson::Value &object() const = 0;
|
||||
virtual double getDouble(const char *key, double defaultValue = 0) const = 0;
|
||||
virtual int getInt(const char *key, int defaultValue = 0) const = 0;
|
||||
virtual int64_t getInt64(const char *key, int64_t defaultValue = 0) const = 0;
|
||||
virtual String getString(const char *key, size_t maxSize) const = 0;
|
||||
virtual uint64_t getUint64(const char *key, uint64_t defaultValue = 0) const = 0;
|
||||
virtual unsigned getUint(const char *key, unsigned defaultValue = 0) const = 0;
|
||||
};
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -27,8 +20,11 @@
|
|||
#define XMRIG_ILOGBACKEND_H
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -37,9 +33,12 @@ namespace xmrig {
|
|||
class ILogBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(ILogBackend)
|
||||
|
||||
ILogBackend() = default;
|
||||
virtual ~ILogBackend() = default;
|
||||
|
||||
virtual void print(int level, const char *line, size_t offset, size_t size, bool colors) = 0;
|
||||
virtual void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -95,7 +95,7 @@ void xmrig::FetchRequest::setBody(const rapidjson::Value &value)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::fetch(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener, int type)
|
||||
void xmrig::fetch(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener, int type, uint64_t rpcId)
|
||||
{
|
||||
# ifdef APP_DEBUG
|
||||
LOG_DEBUG(CYAN("http%s://%s:%u ") MAGENTA_BOLD("\"%s %s\"") BLACK_BOLD(" body: ") CYAN_BOLD("%zu") BLACK_BOLD(" bytes"),
|
||||
|
@ -109,14 +109,15 @@ void xmrig::fetch(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listen
|
|||
HttpClient *client;
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
if (req.tls) {
|
||||
client = new HttpsClient(std::move(req), listener);
|
||||
client = new HttpsClient(tag, std::move(req), listener);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
client = new HttpClient(std::move(req), listener);
|
||||
client = new HttpClient(tag, std::move(req), listener);
|
||||
}
|
||||
|
||||
client->userType = type;
|
||||
client->rpcId = rpcId;
|
||||
client->connect();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -58,10 +58,11 @@ public:
|
|||
String host;
|
||||
String path;
|
||||
uint16_t port = 0;
|
||||
uint64_t timeout = 0;
|
||||
};
|
||||
|
||||
|
||||
void fetch(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener, int type = 0);
|
||||
void fetch(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener, int type = 0, uint64_t rpcId = 0);
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -30,6 +24,7 @@
|
|||
#include "base/kernel/Platform.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/tools/Timer.h"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
@ -44,21 +39,20 @@ static const char *kCRLF = "\r\n";
|
|||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::HttpClient::HttpClient(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener) :
|
||||
xmrig::HttpClient::HttpClient(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener) :
|
||||
HttpContext(HTTP_RESPONSE, listener),
|
||||
m_tag(tag),
|
||||
m_req(std::move(req))
|
||||
{
|
||||
method = m_req.method;
|
||||
url = std::move(m_req.path);
|
||||
body = std::move(m_req.body);
|
||||
headers = std::move(m_req.headers);
|
||||
m_dns = new Dns(this);
|
||||
m_dns = std::make_shared<Dns>(this);
|
||||
|
||||
if (m_req.timeout) {
|
||||
m_timer = std::make_shared<Timer>(this, m_req.timeout, 0);
|
||||
}
|
||||
|
||||
|
||||
xmrig::HttpClient::~HttpClient()
|
||||
{
|
||||
delete m_dns;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,7 +68,7 @@ void xmrig::HttpClient::onResolved(const Dns &dns, int status)
|
|||
|
||||
if (status < 0 && dns.isEmpty()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s:%d] DNS error: \"%s\"", dns.host().data(), port(), uv_strerror(status));
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(status));
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -91,6 +85,12 @@ void xmrig::HttpClient::onResolved(const Dns &dns, int status)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::HttpClient::onTimer(const Timer *)
|
||||
{
|
||||
close(UV_ETIMEDOUT);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpClient::handshake()
|
||||
{
|
||||
headers.insert({ "Host", host() });
|
||||
|
@ -135,8 +135,12 @@ void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
|
|||
}
|
||||
|
||||
if (status < 0) {
|
||||
if (status == UV_ECANCELED) {
|
||||
status = UV_ETIMEDOUT;
|
||||
}
|
||||
|
||||
if (!client->isQuiet()) {
|
||||
LOG_ERR("[%s:%d] connect error: \"%s\"", client->m_dns->host().data(), client->port(), uv_strerror(status));
|
||||
LOG_ERR("%s " RED("connect error: ") RED_BOLD("\"%s\""), client->tag(), uv_strerror(status));
|
||||
}
|
||||
|
||||
return client->close(status);
|
||||
|
@ -151,7 +155,7 @@ void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
|
|||
client->read(buf->base, static_cast<size_t>(nread));
|
||||
} else {
|
||||
if (!client->isQuiet() && nread != UV_EOF) {
|
||||
LOG_ERR("[%s:%d] read error: \"%s\"", client->m_dns->host().data(), client->port(), uv_strerror(static_cast<int>(nread)));
|
||||
LOG_ERR("%s " RED("read error: ") RED_BOLD("\"%s\""), client->tag(), uv_strerror(static_cast<int>(nread)));
|
||||
}
|
||||
|
||||
client->close(static_cast<int>(nread));
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -29,6 +23,7 @@
|
|||
|
||||
|
||||
#include "base/kernel/interfaces/IDnsListener.h"
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
#include "base/net/http/Fetch.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
@ -40,22 +35,24 @@ namespace xmrig {
|
|||
class String;
|
||||
|
||||
|
||||
class HttpClient : public HttpContext, public IDnsListener
|
||||
class HttpClient : public HttpContext, public IDnsListener, public ITimerListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpClient);
|
||||
|
||||
HttpClient(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener);
|
||||
~HttpClient() override;
|
||||
HttpClient(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener);
|
||||
~HttpClient() override = default;
|
||||
|
||||
inline bool isQuiet() const { return m_req.quiet; }
|
||||
inline const char *host() const override { return m_req.host; }
|
||||
inline const char *tag() const { return m_tag; }
|
||||
inline uint16_t port() const override { return m_req.port; }
|
||||
|
||||
bool connect();
|
||||
|
||||
protected:
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onTimer(const Timer *timer) override;
|
||||
|
||||
virtual void handshake();
|
||||
virtual void read(const char *data, size_t size);
|
||||
|
@ -66,8 +63,10 @@ protected:
|
|||
private:
|
||||
static void onConnect(uv_connect_t *req, int status);
|
||||
|
||||
Dns *m_dns;
|
||||
const char *m_tag;
|
||||
FetchRequest m_req;
|
||||
std::shared_ptr<Dns> m_dns;
|
||||
std::shared_ptr<Timer> m_timer;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -160,6 +154,10 @@ uint64_t xmrig::HttpContext::elapsed() const
|
|||
|
||||
void xmrig::HttpContext::close(int status)
|
||||
{
|
||||
if (!get(id())) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto listener = httpListener();
|
||||
|
||||
if (status < 0 && listener) {
|
||||
|
@ -262,7 +260,7 @@ void xmrig::HttpContext::attach(http_parser_settings *settings)
|
|||
|
||||
settings->on_body = [](http_parser *parser, const char *at, size_t len) -> int
|
||||
{
|
||||
static_cast<HttpContext*>(parser->data)->body += std::string(at, len);
|
||||
static_cast<HttpContext*>(parser->data)->body.append(at, len);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -29,20 +29,13 @@ namespace xmrig {
|
|||
class HttpListener : public IHttpListener
|
||||
{
|
||||
public:
|
||||
inline HttpListener(IHttpListener *listener, const char *tag = nullptr) :
|
||||
# ifdef APP_DEBUG
|
||||
m_tag(tag),
|
||||
# endif
|
||||
m_listener(listener)
|
||||
{}
|
||||
inline HttpListener(IHttpListener *listener, const char *tag = nullptr) : m_tag(tag), m_listener(listener) {}
|
||||
|
||||
protected:
|
||||
void onHttpData(const HttpData &data) override;
|
||||
|
||||
private:
|
||||
# ifdef APP_DEBUG
|
||||
const char *m_tag;
|
||||
# endif
|
||||
IHttpListener *m_listener;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -31,7 +25,7 @@
|
|||
|
||||
#include "base/net/https/HttpsClient.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -39,8 +33,8 @@
|
|||
#endif
|
||||
|
||||
|
||||
xmrig::HttpsClient::HttpsClient(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener) :
|
||||
HttpClient(std::move(req), listener)
|
||||
xmrig::HttpsClient::HttpsClient(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener) :
|
||||
HttpClient(tag, std::move(req), listener)
|
||||
{
|
||||
m_ctx = SSL_CTX_new(SSLv23_method());
|
||||
assert(m_ctx != nullptr);
|
||||
|
@ -182,7 +176,7 @@ bool xmrig::HttpsClient::verifyFingerprint(X509 *cert)
|
|||
return false;
|
||||
}
|
||||
|
||||
Buffer::toHex(md, 32, m_fingerprint);
|
||||
Cvt::toHex(m_fingerprint, sizeof(m_fingerprint), md, 32);
|
||||
|
||||
return req().fingerprint.isNull() || strncasecmp(m_fingerprint, req().fingerprint.data(), 64) == 0;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -46,7 +40,7 @@ class HttpsClient : public HttpClient
|
|||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpsClient)
|
||||
|
||||
HttpsClient(FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener);
|
||||
HttpsClient(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttpListener> &listener);
|
||||
~HttpsClient() override;
|
||||
|
||||
const char *tlsFingerprint() const override;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/stratum/Socks5.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
@ -202,11 +202,8 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
|||
char *nonce = m_sendBuf.data();
|
||||
char *data = m_sendBuf.data() + 16;
|
||||
|
||||
Buffer::toHex(reinterpret_cast<const char*>(&result.nonce), 4, nonce);
|
||||
nonce[8] = '\0';
|
||||
|
||||
Buffer::toHex(result.result(), 32, data);
|
||||
data[64] = '\0';
|
||||
Cvt::toHex(nonce, sizeof(uint32_t) * 2 + 1, reinterpret_cast<const uint8_t *>(&result.nonce), sizeof(uint32_t));
|
||||
Cvt::toHex(data, 65, result.result(), 32);
|
||||
# endif
|
||||
|
||||
Document doc(kObjectType);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
#include "base/net/stratum/SubmitResult.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "base/tools/Timer.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
@ -54,7 +54,7 @@ static const char *kHash = "hash";
|
|||
static const char *kHeight = "height";
|
||||
static const char *kJsonRPC = "/json_rpc";
|
||||
|
||||
static const size_t BlobReserveSize = 8;
|
||||
static constexpr size_t kBlobReserveSize = 8;
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
|
|||
# ifdef XMRIG_PROXY_PROJECT
|
||||
memcpy(data + 78, result.nonce, 8);
|
||||
# else
|
||||
Buffer::toHex(reinterpret_cast<const uint8_t *>(&result.nonce), 4, data + 78);
|
||||
Cvt::toHex(data + 78, 9, reinterpret_cast<const uint8_t *>(&result.nonce), 4);
|
||||
# endif
|
||||
|
||||
using namespace rapidjson;
|
||||
|
@ -227,7 +227,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
m_blockhashingblob = Json::getString(params, "blockhashing_blob");
|
||||
if (m_apiVersion == API_DERO) {
|
||||
const uint64_t offset = Json::getUint64(params, "reserved_offset");
|
||||
Buffer::toHex(Buffer::randomBytes(BlobReserveSize).data(), BlobReserveSize, m_blockhashingblob.data() + offset * 2);
|
||||
Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2 + 1, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize);
|
||||
}
|
||||
|
||||
if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) {
|
||||
|
@ -315,10 +315,10 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
|
|||
Value params(kObjectType);
|
||||
params.AddMember("wallet_address", m_user.toJSON(), allocator);
|
||||
if (m_apiVersion == API_DERO) {
|
||||
params.AddMember("reserve_size", static_cast<uint64_t>(BlobReserveSize), allocator);
|
||||
params.AddMember("reserve_size", static_cast<uint64_t>(kBlobReserveSize), allocator);
|
||||
}
|
||||
else {
|
||||
params.AddMember("extra_nonce", Buffer::randomBytes(BlobReserveSize).toHex().toJSON(doc), allocator);
|
||||
params.AddMember("extra_nonce", Cvt::toHex(Cvt::randomBytes(kBlobReserveSize)).toJSON(doc), allocator);
|
||||
}
|
||||
|
||||
JsonRequest::create(doc, m_sequence, "getblocktemplate", params);
|
||||
|
@ -330,7 +330,7 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
|
|||
int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc)
|
||||
{
|
||||
FetchRequest req(HTTP_POST, m_pool.host(), m_pool.port(), kJsonRPC, doc, m_pool.isTLS(), isQuiet());
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
|
||||
return m_sequence++;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void xmrig::DaemonClient::retry()
|
|||
void xmrig::DaemonClient::send(const char *path)
|
||||
{
|
||||
FetchRequest req(HTTP_GET, m_pool.host(), m_pool.port(), path, m_pool.isTLS(), isQuiet());
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
|
||||
|
||||
xmrig::Job::Job(bool nicehash, const Algorithm &algorithm, const String &clientId) :
|
||||
|
@ -63,7 +64,7 @@ bool xmrig::Job::setBlob(const char *blob)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Buffer::fromHex(blob, m_size * 2, m_blob)) {
|
||||
if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, m_size * 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -90,9 +91,9 @@ bool xmrig::Job::setSeedHash(const char *hash)
|
|||
m_rawSeedHash = hash;
|
||||
# endif
|
||||
|
||||
m_seed = Buffer::fromHex(hash, kMaxSeedSize * 2);
|
||||
m_seed = Cvt::fromHex(hash, kMaxSeedSize * 2);
|
||||
|
||||
return !m_seed.isEmpty();
|
||||
return !m_seed.empty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,27 +103,14 @@ bool xmrig::Job::setTarget(const char *target)
|
|||
return false;
|
||||
}
|
||||
|
||||
const size_t len = strlen(target);
|
||||
const auto raw = Cvt::fromHex(target, strlen(target));
|
||||
const size_t size = raw.size();
|
||||
|
||||
if (len <= 8) {
|
||||
uint32_t tmp = 0;
|
||||
char str[8];
|
||||
memcpy(str, target, len);
|
||||
|
||||
if (!Buffer::fromHex(str, 8, reinterpret_cast<uint8_t *>(&tmp)) || tmp == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / static_cast<uint64_t>(tmp));
|
||||
}
|
||||
else if (len <= 16) {
|
||||
m_target = 0;
|
||||
char str[16];
|
||||
memcpy(str, target, len);
|
||||
|
||||
if (!Buffer::fromHex(str, 16, reinterpret_cast<uint8_t *>(&m_target)) || m_target == 0) {
|
||||
return false;
|
||||
if (size == 4) {
|
||||
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
|
||||
}
|
||||
else if (size == 8) {
|
||||
m_target = *reinterpret_cast<const uint64_t *>(raw.data());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
|
|
@ -154,7 +154,7 @@ void xmrig::SelfSelectClient::getBlockTemplate()
|
|||
JsonRequest::create(doc, m_sequence++, "getblocktemplate", params);
|
||||
|
||||
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "base/net/stratum/Tls.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -183,7 +183,7 @@ bool xmrig::Client::Tls::verifyFingerprint(X509 *cert)
|
|||
return false;
|
||||
}
|
||||
|
||||
Buffer::toHex(md, 32, m_fingerprint);
|
||||
Cvt::toHex(m_fingerprint, sizeof(m_fingerprint), md, 32);
|
||||
const char *fingerprint = m_client->m_pool.fingerprint();
|
||||
|
||||
return fingerprint == nullptr || strncasecmp(m_fingerprint, fingerprint, 64) == 0;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
#include "base/net/stratum/benchmark/BenchConfig.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
@ -217,7 +218,7 @@ bool xmrig::BenchClient::setSeed(const char *seed)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Buffer::fromHex(seed, size * 2, m_job.blob())) {
|
||||
if (!Cvt::fromHex(m_job.blob(), m_job.size(), seed, size * 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -321,7 +322,7 @@ void xmrig::BenchClient::send(Request request)
|
|||
case GET_BENCH:
|
||||
{
|
||||
FetchRequest req(HTTP_GET, m_ip, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -335,7 +336,7 @@ void xmrig::BenchClient::send(Request request)
|
|||
doc.AddMember("cpu", Cpu::toJSON(doc), allocator);
|
||||
|
||||
FetchRequest req(HTTP_POST, m_ip, BenchConfig::kApiPort, "/1/benchmark", doc, BenchConfig::kApiTLS, true);
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -374,6 +375,6 @@ void xmrig::BenchClient::update(const rapidjson::Value &body)
|
|||
FetchRequest req(HTTP_PATCH, m_ip, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), body, BenchConfig::kApiTLS, true);
|
||||
req.headers.insert({ "Authorization", fmt::format("Bearer {}", m_token)});
|
||||
|
||||
fetch(std::move(req), m_httpListener);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -20,6 +20,7 @@
|
|||
#include "base/net/tls/ServerTls.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <openssl/ssl.h>
|
||||
|
@ -39,11 +40,23 @@ xmrig::ServerTls::~ServerTls()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::ServerTls::isHTTP(const char *data, size_t size)
|
||||
{
|
||||
assert(size > 0);
|
||||
|
||||
static const char test[6] = "GET /";
|
||||
|
||||
return size > 0 && memcmp(data, test, std::min(size, sizeof(test) - 1)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::ServerTls::isTLS(const char *data, size_t size)
|
||||
{
|
||||
assert(size > 0);
|
||||
|
||||
static const uint8_t test[3] = { 0x16, 0x03, 0x01 };
|
||||
|
||||
return size >= sizeof(test) && memcmp(data, test, sizeof(test)) == 0;
|
||||
return size > 0 && memcmp(data, test, std::min(size, sizeof(test))) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -41,6 +41,7 @@ public:
|
|||
ServerTls(SSL_CTX *ctx);
|
||||
virtual ~ServerTls();
|
||||
|
||||
static bool isHTTP(const char *data, size_t size);
|
||||
static bool isTLS(const char *data, size_t size);
|
||||
|
||||
bool send(const char *data, size_t size);
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
|
||||
#include "base/net/tools/LineReader.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/kernel/constants.h"
|
||||
#include "base/kernel/interfaces/ILineListener.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
@ -55,7 +56,7 @@ void xmrig::LineReader::reset()
|
|||
|
||||
void xmrig::LineReader::add(const char *data, size_t size)
|
||||
{
|
||||
if (size > NetBuffer::kChunkSize - m_pos) {
|
||||
if (size > XMRIG_NET_BUFFER_CHUNK_SIZE - m_pos) {
|
||||
// it breakes correctness silently for long lines
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -20,10 +20,10 @@
|
|||
#define XMRIG_MEMPOOL_H
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -17,8 +17,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "base/net/tools/MemPool.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/kernel/constants.h"
|
||||
#include "base/net/tools/MemPool.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
|
@ -28,14 +29,13 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static constexpr size_t kInitSize = 4;
|
||||
static MemPool<NetBuffer::kChunkSize, kInitSize> *pool = nullptr;
|
||||
static MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *pool = nullptr;
|
||||
|
||||
|
||||
inline MemPool<NetBuffer::kChunkSize, kInitSize> *getPool()
|
||||
inline MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *getPool()
|
||||
{
|
||||
if (!pool) {
|
||||
pool = new MemPool<NetBuffer::kChunkSize, kInitSize>();
|
||||
pool = new MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS>();
|
||||
}
|
||||
|
||||
return pool;
|
||||
|
@ -67,17 +67,25 @@ void xmrig::NetBuffer::destroy()
|
|||
void xmrig::NetBuffer::onAlloc(uv_handle_t *, size_t, uv_buf_t *buf)
|
||||
{
|
||||
buf->base = getPool()->allocate();
|
||||
buf->len = kChunkSize;
|
||||
buf->len = XMRIG_NET_BUFFER_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const char *buf)
|
||||
{
|
||||
if (buf == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPool()->deallocate(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const uv_buf_t *buf)
|
||||
{
|
||||
if (buf->base == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPool()->deallocate(buf->base);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -33,8 +33,6 @@ namespace xmrig {
|
|||
class NetBuffer
|
||||
{
|
||||
public:
|
||||
static constexpr size_t kChunkSize = 16 * 1024;
|
||||
|
||||
static char *allocate();
|
||||
static void destroy();
|
||||
static void onAlloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf);
|
||||
|
|
|
@ -1,231 +0,0 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/tools/Buffer.h"
|
||||
|
||||
|
||||
#include <random>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static std::random_device randomDevice;
|
||||
static std::mt19937 randomEngine(randomDevice());
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
static inline uint8_t hf_hex2bin(uint8_t c, bool &err)
|
||||
{
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
}
|
||||
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
return c - 'a' + 0xA;
|
||||
}
|
||||
|
||||
if (c >= 'A' && c <= 'F') {
|
||||
return c - 'A' + 0xA;
|
||||
}
|
||||
|
||||
err = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline uint8_t hf_bin2hex(uint8_t c)
|
||||
{
|
||||
if (c <= 0x9) {
|
||||
return '0' + c;
|
||||
}
|
||||
|
||||
return 'a' - 0xA + c;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer::Buffer(Buffer &&other) noexcept :
|
||||
m_data(other.m_data),
|
||||
m_size(other.m_size)
|
||||
{
|
||||
other.m_data = nullptr;
|
||||
other.m_size = 0;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer::Buffer(const Buffer &other)
|
||||
{
|
||||
copy(other.data(), other.size());
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer::Buffer(const char *data, size_t size)
|
||||
{
|
||||
copy(data, size);
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer::Buffer(size_t size) :
|
||||
m_size(size)
|
||||
{
|
||||
if (size > 0) {
|
||||
m_data = new char[size]();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer::~Buffer()
|
||||
{
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Buffer::from(const char *data, size_t size)
|
||||
{
|
||||
if (m_size > 0) {
|
||||
if (m_size == size) {
|
||||
memcpy(m_data, data, m_size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
copy(data, size);
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer xmrig::Buffer::allocUnsafe(size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Buffer buf;
|
||||
buf.m_size = size;
|
||||
buf.m_data = new char[size];
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer xmrig::Buffer::randomBytes(const size_t size)
|
||||
{
|
||||
Buffer buf(size);
|
||||
std::uniform_int_distribution<> dis(0, 255);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
buf.m_data[i] = static_cast<char>(dis(randomEngine));
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Buffer::fromHex(const uint8_t *in, size_t size, uint8_t *out)
|
||||
{
|
||||
bool error = false;
|
||||
for (size_t i = 0; i < size; i += 2) {
|
||||
out[i / 2] = static_cast<uint8_t>((hf_hex2bin(in[i], error) << 4) | hf_hex2bin(in[i + 1], error));
|
||||
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer xmrig::Buffer::fromHex(const char *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size % 2 != 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Buffer buf(size / 2);
|
||||
if (!fromHex(data, size, buf.data())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Buffer::toHex(const uint8_t *in, size_t size, uint8_t *out)
|
||||
{
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
out[i * 2] = hf_bin2hex((in[i] & 0xF0) >> 4);
|
||||
out[i * 2 + 1] = hf_bin2hex(in[i] & 0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Buffer::toHex() const
|
||||
{
|
||||
if (m_size == 0) {
|
||||
return String();
|
||||
}
|
||||
|
||||
char *buf = new char[m_size * 2 + 1];
|
||||
buf[m_size * 2] = '\0';
|
||||
|
||||
toHex(m_data, m_size, buf);
|
||||
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Buffer::copy(const char *data, size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
m_data = nullptr;
|
||||
m_size = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[size];
|
||||
m_size = size;
|
||||
|
||||
memcpy(m_data, data, m_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Buffer::move(Buffer &&other)
|
||||
{
|
||||
if (m_size > 0) {
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
m_data = other.m_data;
|
||||
m_size = other.m_size;
|
||||
|
||||
other.m_data = nullptr;
|
||||
other.m_size = 0;
|
||||
}
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -26,67 +20,14 @@
|
|||
#define XMRIG_BUFFER_H
|
||||
|
||||
|
||||
#include "base/tools/String.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
Buffer() = default;
|
||||
Buffer(Buffer &&other) noexcept;
|
||||
Buffer(const Buffer &other);
|
||||
Buffer(const char *data, size_t size);
|
||||
Buffer(size_t size);
|
||||
~Buffer();
|
||||
|
||||
|
||||
inline bool isEmpty() const { return size() == 0; }
|
||||
inline bool isEqual(const Buffer &other) const { return m_size == other.m_size && (m_size == 0 || memcmp(m_data, other.m_data, m_size) == 0); }
|
||||
inline char *data() { return m_data; }
|
||||
inline const char *data() const { return m_data; }
|
||||
inline size_t size() const { return m_size; }
|
||||
inline void from(const Buffer &other) { from(other.data(), other.size()); }
|
||||
|
||||
|
||||
void from(const char *data, size_t size);
|
||||
|
||||
|
||||
inline bool operator!=(const Buffer &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Buffer &other) const { return isEqual(other); }
|
||||
inline Buffer &operator=(Buffer &&other) noexcept { move(std::move(other)); return *this; }
|
||||
inline Buffer &operator=(const Buffer &other) { from(other); return *this; }
|
||||
|
||||
|
||||
static Buffer allocUnsafe(size_t size);
|
||||
static Buffer randomBytes(const size_t size);
|
||||
|
||||
static inline Buffer alloc(size_t size) { return Buffer(size); }
|
||||
|
||||
|
||||
inline static bool fromHex(const char *in, size_t size, char *out) { return fromHex(reinterpret_cast<const uint8_t *>(in), size, reinterpret_cast<uint8_t *>(out)); }
|
||||
inline static bool fromHex(const char *in, size_t size, uint8_t *out) { return fromHex(reinterpret_cast<const uint8_t *>(in), size, out); }
|
||||
inline static Buffer fromHex(const char *data) { return fromHex(data, strlen(data)); }
|
||||
inline static Buffer fromHex(const String &str) { return fromHex(str.data(), str.size()); }
|
||||
inline static String toHex(const char *in, size_t size) { return Buffer(in, size).toHex(); }
|
||||
inline static String toHex(const uint8_t *in, size_t size) { return Buffer(reinterpret_cast<const char *>(in), size).toHex(); }
|
||||
inline static void toHex(const char *in, size_t size, char *out) { return toHex(reinterpret_cast<const uint8_t *>(in), size, reinterpret_cast<uint8_t *>(out)); }
|
||||
inline static void toHex(const uint8_t *in, size_t size, char *out) { return toHex(in, size, reinterpret_cast<uint8_t *>(out)); }
|
||||
|
||||
static bool fromHex(const uint8_t *in, size_t size, uint8_t *out);
|
||||
static Buffer fromHex(const char *data, size_t size);
|
||||
static void toHex(const uint8_t *in, size_t size, uint8_t *out);
|
||||
String toHex() const;
|
||||
|
||||
private:
|
||||
void copy(const char *data, size_t size);
|
||||
void move(Buffer &&other);
|
||||
|
||||
char *m_data = nullptr;
|
||||
size_t m_size = 0;
|
||||
};
|
||||
using Buffer = std::vector<uint8_t>;
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
|
275
src/base/tools/Cvt.cpp
Normal file
275
src/base/tools/Cvt.cpp
Normal file
|
@ -0,0 +1,275 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2013-2020 Frank Denis <j at pureftpd dot org>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <random>
|
||||
|
||||
|
||||
#ifdef XMRIG_SODIUM
|
||||
# include <sodium.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
#ifndef XMRIG_SODIUM
|
||||
static std::random_device randomDevice;
|
||||
static std::mt19937 randomEngine(randomDevice());
|
||||
|
||||
|
||||
static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigned char *const bin, const size_t bin_len)
|
||||
{
|
||||
size_t i = 0U;
|
||||
unsigned int x;
|
||||
int b;
|
||||
int c;
|
||||
|
||||
if (bin_len >= SIZE_MAX / 2 || hex_maxlen <= bin_len * 2U) {
|
||||
return nullptr; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
|
||||
while (i < bin_len) {
|
||||
c = bin[i] & 0xf;
|
||||
b = bin[i] >> 4;
|
||||
x = (unsigned char) (87U + c + (((c - 10U) >> 8) & ~38U)) << 8 |
|
||||
(unsigned char) (87U + b + (((b - 10U) >> 8) & ~38U));
|
||||
hex[i * 2U] = (char) x;
|
||||
x >>= 8;
|
||||
hex[i * 2U + 1U] = (char) x;
|
||||
i++;
|
||||
}
|
||||
hex[i * 2U] = 0U;
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
|
||||
static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const char *const hex, const size_t hex_len, const char *const ignore, size_t *const bin_len, const char **const hex_end)
|
||||
{
|
||||
size_t bin_pos = 0U;
|
||||
size_t hex_pos = 0U;
|
||||
int ret = 0;
|
||||
unsigned char c;
|
||||
unsigned char c_acc = 0U;
|
||||
unsigned char c_alpha0;
|
||||
unsigned char c_alpha;
|
||||
unsigned char c_num0;
|
||||
unsigned char c_num;
|
||||
unsigned char c_val;
|
||||
unsigned char state = 0U;
|
||||
|
||||
while (hex_pos < hex_len) {
|
||||
c = (unsigned char) hex[hex_pos];
|
||||
c_num = c ^ 48U;
|
||||
c_num0 = (c_num - 10U) >> 8;
|
||||
c_alpha = (c & ~32U) - 55U;
|
||||
c_alpha0 = ((c_alpha - 10U) ^ (c_alpha - 16U)) >> 8;
|
||||
|
||||
if ((c_num0 | c_alpha0) == 0U) {
|
||||
if (ignore != nullptr && state == 0U && strchr(ignore, c) != nullptr) {
|
||||
hex_pos++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
c_val = (c_num0 & c_num) | (c_alpha0 & c_alpha);
|
||||
|
||||
if (bin_pos >= bin_maxlen) {
|
||||
ret = -1;
|
||||
errno = ERANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (state == 0U) {
|
||||
c_acc = c_val * 16U;
|
||||
} else {
|
||||
bin[bin_pos++] = c_acc | c_val;
|
||||
}
|
||||
|
||||
state = ~state;
|
||||
hex_pos++;
|
||||
}
|
||||
|
||||
if (state != 0U) {
|
||||
hex_pos--;
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
bin_pos = 0U;
|
||||
}
|
||||
|
||||
if (hex_end != nullptr) {
|
||||
*hex_end = &hex[hex_pos];
|
||||
} else if (hex_pos != hex_len) {
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (bin_len != nullptr) {
|
||||
*bin_len = bin_pos;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define sodium_bin2hex cvt_bin2hex
|
||||
#define sodium_hex2bin cvt_hex2bin
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool fromHexImpl(T &buf, const char *in, size_t size)
|
||||
{
|
||||
assert(in != nullptr && size > 0);
|
||||
if (in == nullptr || size == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buf.resize(size / 2);
|
||||
|
||||
return sodium_hex2bin(reinterpret_cast<uint8_t *>(&buf.front()), buf.size(), in, size, nullptr, nullptr, nullptr) == 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
bool xmrig::Cvt::fromHex(Buffer &buf, const char *in, size_t size)
|
||||
{
|
||||
return fromHexImpl(buf, in, size);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Cvt::fromHex(Buffer &buf, const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsString()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return fromHexImpl(buf, value.GetString(), value.GetStringLength());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Cvt::fromHex(std::string &buf, const char *in, size_t size)
|
||||
{
|
||||
return fromHexImpl(buf, in, size);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Cvt::fromHex(uint8_t *bin, size_t bin_maxlen, const char *hex, size_t hex_len)
|
||||
{
|
||||
assert(hex != nullptr && hex_len > 0);
|
||||
if (hex == nullptr || hex_len == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return sodium_hex2bin(bin, bin_maxlen, hex, hex_len, nullptr, nullptr, nullptr) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Cvt::fromHex(uint8_t *bin, size_t max, const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsString()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return fromHex(bin, max, value.GetString(), value.GetStringLength());
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer xmrig::Cvt::fromHex(const char *in, size_t size)
|
||||
{
|
||||
Buffer buf;
|
||||
if (!fromHex(buf, in, size)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Cvt::toHex(char *hex, size_t hex_maxlen, const uint8_t *bin, size_t bin_len)
|
||||
{
|
||||
return sodium_bin2hex(hex, hex_maxlen, bin, bin_len) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Buffer xmrig::Cvt::randomBytes(const size_t size)
|
||||
{
|
||||
Buffer buf(size);
|
||||
|
||||
# ifndef XMRIG_SODIUM
|
||||
std::uniform_int_distribution<> dis(0, 255);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
buf[i] = static_cast<char>(dis(randomEngine));
|
||||
}
|
||||
# else
|
||||
randombytes_buf(buf.data(), size);
|
||||
# endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Cvt::toHex(const Buffer &data, rapidjson::Document &doc)
|
||||
{
|
||||
return toHex(data.data(), data.size(), doc);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Cvt::toHex(const std::string &data, rapidjson::Document &doc)
|
||||
{
|
||||
return toHex(reinterpret_cast<const uint8_t *>(data.data()), data.size(), doc);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Cvt::toHex(const uint8_t *in, size_t size, rapidjson::Document &doc)
|
||||
{
|
||||
return toHex(in, size).toJSON(doc);
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size)
|
||||
{
|
||||
assert(in != nullptr && size > 0);
|
||||
if (in == nullptr || size == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const size_t hex_maxlen = size * 2 + 1;
|
||||
|
||||
char *buf = new char[hex_maxlen];
|
||||
if (!toHex(buf, hex_maxlen, in, size)) {
|
||||
delete [] buf;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
61
src/base/tools/Cvt.h
Normal file
61
src/base/tools/Cvt.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CVT_H
|
||||
#define XMRIG_CVT_H
|
||||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Cvt
|
||||
{
|
||||
public:
|
||||
inline static bool fromHex(Buffer &buf, const String &hex) { return fromHex(buf, hex.data(), hex.size()); }
|
||||
inline static Buffer fromHex(const std::string &hex) { return fromHex(hex.data(), hex.size()); }
|
||||
inline static Buffer fromHex(const String &hex) { return fromHex(hex.data(), hex.size()); }
|
||||
inline static String toHex(const Buffer &data) { return toHex(data.data(), data.size()); }
|
||||
inline static String toHex(const std::string &data) { return toHex(reinterpret_cast<const uint8_t *>(data.data()), data.size()); }
|
||||
|
||||
static bool fromHex(Buffer &buf, const char *in, size_t size);
|
||||
static bool fromHex(Buffer &buf, const rapidjson::Value &value);
|
||||
static bool fromHex(std::string &buf, const char *in, size_t size);
|
||||
static bool fromHex(uint8_t *bin, size_t bin_maxlen, const char *hex, size_t hex_len);
|
||||
static bool fromHex(uint8_t *bin, size_t bin_maxlen, const rapidjson::Value &value);
|
||||
static bool toHex(char *hex, size_t hex_maxlen, const uint8_t *bin, size_t bin_len);
|
||||
static Buffer fromHex(const char *in, size_t size);
|
||||
static Buffer randomBytes(size_t size);
|
||||
static rapidjson::Value toHex(const Buffer &data, rapidjson::Document &doc);
|
||||
static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc);
|
||||
static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc);
|
||||
static String toHex(const uint8_t *in, size_t size);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_CVT_H */
|
|
@ -38,12 +38,10 @@
|
|||
#include "base/kernel/Platform.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/tools/Profiler.h"
|
||||
#include "base/tools/Timer.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "crypto/common/Nonce.h"
|
||||
#include "crypto/rx/Rx.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
@ -64,6 +62,8 @@
|
|||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/rx/Profiler.h"
|
||||
# include "crypto/rx/Rx.h"
|
||||
# include "crypto/rx/RxConfig.h"
|
||||
#endif
|
||||
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < hr->threads(); i++) {
|
||||
for (size_t i = 0; i < hr->threads(); i++) {
|
||||
Value thread(kArrayType);
|
||||
thread.PushBack(Hashrate::normalize(hr->calc(i, Hashrate::ShortInterval)), allocator);
|
||||
thread.PushBack(Hashrate::normalize(hr->calc(i, Hashrate::MediumInterval)), allocator);
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,8 +17,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -57,6 +51,7 @@ public:
|
|||
rapidjson::Value toJSON() const;
|
||||
|
||||
inline bool isEqual(const Assembly &other) const { return m_id == other.m_id; }
|
||||
inline Id id() const { return m_id; }
|
||||
|
||||
inline bool operator!=(Assembly::Id id) const { return m_id != id; }
|
||||
inline bool operator!=(const Assembly &other) const { return !isEqual(other); }
|
||||
|
|
|
@ -30,10 +30,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <vector>
|
||||
|
||||
#include "crypto/randomx/aes_hash.hpp"
|
||||
#include "crypto/randomx/soft_aes.h"
|
||||
#include "crypto/randomx/randomx.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Profiler.h"
|
||||
#include "crypto/randomx/randomx.h"
|
||||
#include "crypto/randomx/soft_aes.h"
|
||||
#include "crypto/rx/Profiler.h"
|
||||
|
||||
#define AES_HASH_1R_STATE0 0xd7983aad, 0xcc82db47, 0x9fa856de, 0x92b52c0d
|
||||
#define AES_HASH_1R_STATE1 0xace78057, 0xf59e125a, 0x15c7b798, 0x338d996e
|
||||
|
|
|
@ -31,13 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <climits>
|
||||
#include <atomic>
|
||||
#include "crypto/randomx/jit_compiler_x86.hpp"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "crypto/randomx/jit_compiler_x86_static.hpp"
|
||||
#include "crypto/randomx/superscalar.hpp"
|
||||
#include "crypto/randomx/program.hpp"
|
||||
#include "crypto/randomx/reciprocal.h"
|
||||
#include "crypto/randomx/superscalar.hpp"
|
||||
#include "crypto/randomx/virtual_memory.hpp"
|
||||
#include "base/tools/Profiler.h"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "crypto/rx/Profiler.h"
|
||||
|
||||
#ifdef XMRIG_FIX_RYZEN
|
||||
# include "crypto/rx/Rx.h"
|
||||
|
|
|
@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#include "base/tools/Profiler.h"
|
||||
#include "crypto/rx/Profiler.h"
|
||||
|
||||
RandomX_ConfigurationWownero::RandomX_ConfigurationWownero()
|
||||
{
|
||||
|
|
|
@ -30,13 +30,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include "crypto/randomx/virtual_machine.hpp"
|
||||
#include "crypto/randomx/common.hpp"
|
||||
#include "crypto/randomx/aes_hash.hpp"
|
||||
#include "crypto/randomx/blake2/blake2.h"
|
||||
#include "crypto/randomx/intrin_portable.h"
|
||||
#include "crypto/randomx/allocator.hpp"
|
||||
#include "crypto/randomx/blake2/blake2.h"
|
||||
#include "crypto/randomx/common.hpp"
|
||||
#include "crypto/randomx/intrin_portable.h"
|
||||
#include "crypto/randomx/soft_aes.h"
|
||||
#include "base/tools/Profiler.h"
|
||||
#include "crypto/rx/Profiler.h"
|
||||
|
||||
randomx_vm::~randomx_vm() {
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue