Move files.
This commit is contained in:
parent
dc87ef6062
commit
ee434a5708
18 changed files with 71 additions and 56 deletions
145
src/backend/common/Threads.cpp
Normal file
145
src/backend/common/Threads.cpp
Normal file
|
@ -0,0 +1,145 @@
|
|||
/* 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>
|
||||
*
|
||||
* 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/Threads.h"
|
||||
#include "backend/cpu/CpuThread.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
template <class T>
|
||||
const std::vector<T> &xmrig::Threads<T>::get(const String &profileName) const
|
||||
{
|
||||
static std::vector<T> empty;
|
||||
if (profileName.isNull() || !has(profileName)) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
return m_profiles.at(profileName);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
xmrig::String xmrig::Threads<T>::profileName(const Algorithm &algorithm, bool strict) const
|
||||
{
|
||||
if (isDisabled(algorithm)) {
|
||||
return String();
|
||||
}
|
||||
|
||||
const String name = algorithm.shortName();
|
||||
if (has(name)) {
|
||||
return name;
|
||||
}
|
||||
|
||||
if (m_aliases.count(algorithm) > 0) {
|
||||
return m_aliases.at(algorithm);
|
||||
}
|
||||
|
||||
if (!strict && name.contains("/")) {
|
||||
const String base = name.split('/').at(0);
|
||||
if (has(base)) {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void xmrig::Threads<T>::read(const rapidjson::Value &value)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
for (auto &member : value.GetObject()) {
|
||||
if (member.value.IsArray()) {
|
||||
std::vector<T> threads;
|
||||
|
||||
for (auto &v : member.value.GetArray()) {
|
||||
T thread(v);
|
||||
if (thread.isValid()) {
|
||||
threads.push_back(std::move(thread));
|
||||
}
|
||||
}
|
||||
|
||||
if (!threads.empty()) {
|
||||
move(member.name.GetString(), std::move(threads));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const Algorithm algo(member.name.GetString());
|
||||
if (!algo.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (member.value.IsBool() && member.value.IsFalse()) {
|
||||
disable(algo);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (member.value.IsString()) {
|
||||
if (has(member.value.GetString())) {
|
||||
m_aliases.insert({ algo, member.value.GetString() });
|
||||
}
|
||||
else {
|
||||
m_disabled.insert(algo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void xmrig::Threads<T>::toJSON(rapidjson::Value &out, rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
for (const auto &kv : m_profiles) {
|
||||
Value arr(kArrayType);
|
||||
|
||||
for (const T &thread : kv.second) {
|
||||
arr.PushBack(thread.toJSON(doc), allocator);
|
||||
}
|
||||
|
||||
out.AddMember(kv.first.toJSON(), arr, allocator);
|
||||
}
|
||||
|
||||
for (const Algorithm &algo : m_disabled) {
|
||||
out.AddMember(StringRef(algo.shortName()), false, allocator);
|
||||
}
|
||||
|
||||
for (const auto &kv : m_aliases) {
|
||||
out.AddMember(StringRef(kv.first.shortName()), kv.second.toJSON(), allocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
template class Threads<CpuThread>;
|
||||
|
||||
} // namespace xmrig
|
67
src/backend/common/Threads.h
Normal file
67
src/backend/common/Threads.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* 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>
|
||||
*
|
||||
* 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_THREADS_H
|
||||
#define XMRIG_THREADS_H
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
||||
#include "base/tools/String.h"
|
||||
#include "crypto/common/Algorithm.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Threads
|
||||
{
|
||||
public:
|
||||
inline bool has(const char *profile) const { return m_profiles.count(profile) > 0; }
|
||||
inline bool isDisabled(const Algorithm &algo) const { return m_disabled.count(algo) > 0; }
|
||||
inline bool isExist(const Algorithm &algo) const { return isDisabled(algo) || m_aliases.count(algo) > 0 || has(algo.shortName()); }
|
||||
inline const std::vector<T> &get(const Algorithm &algo, bool strict = false) const { return get(profileName(algo, strict)); }
|
||||
inline void disable(const Algorithm &algo) { m_disabled.insert(algo); }
|
||||
inline void move(const char *profile, std::vector<T> &&threads) { m_profiles.insert({ profile, threads }); }
|
||||
|
||||
const std::vector<T> &get(const String &profileName) const;
|
||||
String profileName(const Algorithm &algorithm, bool strict = false) const;
|
||||
void read(const rapidjson::Value &value);
|
||||
void toJSON(rapidjson::Value &out, rapidjson::Document &doc) const;
|
||||
|
||||
private:
|
||||
std::map<Algorithm, String> m_aliases;
|
||||
std::map<String, std::vector<T> > m_profiles;
|
||||
std::set<Algorithm> m_disabled;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_THREADS_H */
|
58
src/backend/common/Worker.cpp
Normal file
58
src/backend/common/Worker.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* 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 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <chrono>
|
||||
|
||||
|
||||
#include "backend/common/Worker.h"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "workers/CpuThreadLegacy.h"
|
||||
#include "workers/ThreadHandle.h"
|
||||
|
||||
|
||||
Worker::Worker(ThreadHandle *handle) :
|
||||
m_id(handle->threadId()),
|
||||
m_hashCount(0),
|
||||
m_timestamp(0),
|
||||
m_count(0),
|
||||
m_thread(static_cast<xmrig::CpuThreadLegacy *>(handle->config()))
|
||||
{
|
||||
if (xmrig::Cpu::info()->threads() > 1 && m_thread->affinity() != -1L) {
|
||||
Platform::setThreadAffinity(m_thread->affinity());
|
||||
}
|
||||
|
||||
Platform::setThreadPriority(m_thread->priority());
|
||||
}
|
||||
|
||||
|
||||
void Worker::storeStats()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
const uint64_t timestamp = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
m_hashCount.store(m_count, std::memory_order_relaxed);
|
||||
m_timestamp.store(timestamp, std::memory_order_relaxed);
|
||||
}
|
68
src/backend/common/Worker.h
Normal file
68
src/backend/common/Worker.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* 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 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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_WORKER_H
|
||||
#define XMRIG_WORKER_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "backend/common/interfaces/IWorker.h"
|
||||
#include "Mem.h"
|
||||
|
||||
|
||||
class ThreadHandle;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
class CpuThreadLegacy;
|
||||
}
|
||||
|
||||
|
||||
class Worker : public IWorker
|
||||
{
|
||||
public:
|
||||
Worker(ThreadHandle *handle);
|
||||
|
||||
inline const MemInfo &memory() const { return m_memory; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t hashCount() const override { return m_hashCount.load(std::memory_order_relaxed); }
|
||||
inline uint64_t timestamp() const override { return m_timestamp.load(std::memory_order_relaxed); }
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
|
||||
const size_t m_id;
|
||||
MemInfo m_memory;
|
||||
std::atomic<uint64_t> m_hashCount;
|
||||
std::atomic<uint64_t> m_timestamp;
|
||||
uint64_t m_count;
|
||||
xmrig::CpuThreadLegacy *m_thread;
|
||||
};
|
||||
|
||||
|
||||
#endif /* XMRIG_WORKER_H */
|
143
src/backend/common/WorkerJob.h
Normal file
143
src/backend/common/WorkerJob.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
/* 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>
|
||||
*
|
||||
* 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_WORKERJOB_H
|
||||
#define XMRIG_WORKERJOB_H
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "crypto/common/Nonce.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<size_t N>
|
||||
class WorkerJob
|
||||
{
|
||||
public:
|
||||
inline const Job ¤tJob() const { return m_jobs[index()]; }
|
||||
inline uint32_t *nonce(size_t i = 0) { return reinterpret_cast<uint32_t*>(blob() + (i * currentJob().size()) + 39); }
|
||||
inline uint64_t sequence() const { return m_sequence; }
|
||||
inline uint8_t *blob() { return m_blobs[index()]; }
|
||||
inline uint8_t index() const { return m_index; }
|
||||
|
||||
|
||||
inline void add(const Job &job, uint64_t sequence, uint32_t reserveCount)
|
||||
{
|
||||
m_sequence = sequence;
|
||||
|
||||
if (currentJob() == job) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (index() == 1 && job.index() == 0 && job == m_jobs[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
save(job, reserveCount);
|
||||
}
|
||||
|
||||
|
||||
inline void nextRound(uint32_t reserveCount)
|
||||
{
|
||||
m_rounds[index()]++;
|
||||
|
||||
if ((m_rounds[index()] % reserveCount) == 0) {
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
*nonce(i) = Nonce::next(index(), *nonce(i), reserveCount, currentJob().isNicehash());
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
*nonce(i) += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
inline void save(const Job &job, uint32_t reserveCount)
|
||||
{
|
||||
m_index = job.index();
|
||||
const size_t size = job.size();
|
||||
m_jobs[index()] = job;
|
||||
m_rounds[index()] = 0;
|
||||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
memcpy(m_blobs[index()] + (i * size), job.blob(), size);
|
||||
*nonce(i) = Nonce::next(index(), *nonce(i), reserveCount, job.isNicehash());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
alignas(16) uint8_t m_blobs[2][Job::kMaxBlobSize * N];
|
||||
Job m_jobs[2];
|
||||
uint32_t m_rounds[2] = { 0, 0 };
|
||||
uint64_t m_sequence = 0;
|
||||
uint8_t m_index = 0;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
inline uint32_t *xmrig::WorkerJob<1>::nonce(size_t)
|
||||
{
|
||||
return reinterpret_cast<uint32_t*>(blob() + 39);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline void xmrig::WorkerJob<1>::nextRound(uint32_t reserveCount)
|
||||
{
|
||||
m_rounds[index()]++;
|
||||
|
||||
if ((m_rounds[index()] % reserveCount) == 0) {
|
||||
*nonce() = Nonce::next(index(), *nonce(), reserveCount, currentJob().isNicehash());
|
||||
}
|
||||
else {
|
||||
*nonce() += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline void xmrig::WorkerJob<1>::save(const Job &job, uint32_t reserveCount)
|
||||
{
|
||||
m_index = job.index();
|
||||
m_jobs[index()] = job;
|
||||
m_rounds[index()] = 0;
|
||||
|
||||
memcpy(blob(), job.blob(), job.size());
|
||||
*nonce() = Nonce::next(index(), *nonce(), reserveCount, currentJob().isNicehash());
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_WORKERJOB_H */
|
12
src/backend/common/common.cmake
Normal file
12
src/backend/common/common.cmake
Normal file
|
@ -0,0 +1,12 @@
|
|||
set(HEADERS_BACKEND_COMMON
|
||||
src/backend/common/interfaces/IThread.h
|
||||
src/backend/common/interfaces/IWorker.h
|
||||
src/backend/common/Threads.h
|
||||
src/backend/common/Worker.h
|
||||
src/backend/common/WorkerJob.h
|
||||
)
|
||||
|
||||
set(SOURCES_BACKEND_COMMON
|
||||
src/backend/common/Threads.cpp
|
||||
src/backend/common/Worker.cpp
|
||||
)
|
77
src/backend/common/interfaces/IThread.h
Normal file
77
src/backend/common/interfaces/IThread.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* 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>
|
||||
*
|
||||
* 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_ITHREAD_H
|
||||
#define XMRIG_ITHREAD_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "crypto/common/Algorithm.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IThread
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
CPU,
|
||||
OpenCL,
|
||||
CUDA
|
||||
};
|
||||
|
||||
enum Multiway {
|
||||
SingleWay = 1,
|
||||
DoubleWay,
|
||||
TripleWay,
|
||||
QuadWay,
|
||||
PentaWay
|
||||
};
|
||||
|
||||
virtual ~IThread() = default;
|
||||
|
||||
virtual Algorithm algorithm() const = 0;
|
||||
virtual int priority() const = 0;
|
||||
virtual int64_t affinity() const = 0;
|
||||
virtual Multiway multiway() const = 0;
|
||||
virtual rapidjson::Value toConfig(rapidjson::Document &doc) const = 0;
|
||||
virtual size_t index() const = 0;
|
||||
virtual Type type() const = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
virtual rapidjson::Value toAPI(rapidjson::Document &doc) const = 0;
|
||||
# endif
|
||||
|
||||
# ifdef APP_DEBUG
|
||||
virtual void print() const = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ITHREAD_H
|
45
src/backend/common/interfaces/IWorker.h
Normal file
45
src/backend/common/interfaces/IWorker.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* 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>
|
||||
*
|
||||
* 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_IWORKER_H
|
||||
#define XMRIG_IWORKER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
class IWorker
|
||||
{
|
||||
public:
|
||||
virtual ~IWorker() = default;
|
||||
|
||||
virtual bool selfTest() = 0;
|
||||
virtual size_t id() const = 0;
|
||||
virtual uint64_t hashCount() const = 0;
|
||||
virtual uint64_t timestamp() const = 0;
|
||||
virtual void start() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // XMRIG_IWORKER_H
|
Loading…
Add table
Add a link
Reference in a new issue