This commit is contained in:
MoneroOcean 2020-05-23 11:13:42 -07:00
commit 51c783a313
191 changed files with 1417 additions and 2600 deletions

View file

@ -28,6 +28,8 @@
#include <thread>
#include "core/Miner.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/common/Hashrate.h"
#include "backend/cpu/Cpu.h"
#include "backend/cpu/CpuBackend.h"
@ -38,11 +40,8 @@
#include "base/tools/Timer.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "core/Miner.h"
#include "crypto/common/Nonce.h"
#include "crypto/rx/Rx.h"
#include "crypto/astrobwt/AstroBWT.h"
#include "rapidjson/document.h"
#include "version.h"
@ -67,6 +66,11 @@
#endif
#ifdef XMRIG_ALGO_ASTROBWT
# include "crypto/astrobwt/AstroBWT.h"
#endif
namespace xmrig {
@ -238,15 +242,36 @@ public:
# endif
void printHashrate(bool details)
{
char num[8 * 4] = { 0 };
double speed[3] = { 0.0 };
for (auto backend : backends) {
const auto hashrate = backend->hashrate();
if (hashrate) {
speed[0] += hashrate->calc(Hashrate::ShortInterval);
speed[1] += hashrate->calc(Hashrate::MediumInterval);
speed[2] += hashrate->calc(Hashrate::LargeInterval);
}
backend->printHashrate(details);
}
LOG_INFO(WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s"),
Hashrate::format(speed[0], num, sizeof(num) / 4),
Hashrate::format(speed[1], num + 8, sizeof(num) / 4),
Hashrate::format(speed[2], num + 8 * 2, sizeof(num) / 4 ),
Hashrate::format(maxHashrate[algorithm], num + 8 * 3, sizeof(num) / 4)
);
}
# ifdef XMRIG_ALGO_RANDOMX
inline bool initRX() { return Rx::init(job, controller->config()->rx(), controller->config()->cpu()); }
# endif
# ifdef XMRIG_ALGO_ASTROBWT
inline bool initAstroBWT() { return astrobwt::init(job); }
# endif
Algorithm algorithm;
Algorithms algorithms;
bool active = false;
@ -279,6 +304,10 @@ xmrig::Miner::Miner(Controller *controller)
Rx::init(this);
# endif
# ifdef XMRIG_ALGO_ASTROBWT
astrobwt::init();
# endif
controller->addListener(this);
# ifdef XMRIG_FEATURE_API
@ -345,7 +374,7 @@ void xmrig::Miner::execCommand(char command)
switch (command) {
case 'h':
case 'H':
printHashrate(true);
d_ptr->printHashrate(true);
break;
case 'p':
@ -384,31 +413,6 @@ void xmrig::Miner::pause()
}
void xmrig::Miner::printHashrate(bool details)
{
char num[8 * 4] = { 0 };
double speed[3] = { 0.0 };
for (IBackend *backend : d_ptr->backends) {
const Hashrate *hashrate = backend->hashrate();
if (hashrate) {
speed[0] += hashrate->calc(Hashrate::ShortInterval);
speed[1] += hashrate->calc(Hashrate::MediumInterval);
speed[2] += hashrate->calc(Hashrate::LargeInterval);
}
backend->printHashrate(details);
}
LOG_INFO(WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s"),
Hashrate::format(speed[0], num, sizeof(num) / 4),
Hashrate::format(speed[1], num + 8, sizeof(num) / 4),
Hashrate::format(speed[2], num + 8 * 2, sizeof(num) / 4 ),
Hashrate::format(d_ptr->maxHashrate[d_ptr->algorithm], num + 8 * 3, sizeof(num) / 4)
);
}
void xmrig::Miner::setEnabled(bool enabled)
{
if (d_ptr->enabled == enabled) {
@ -459,14 +463,10 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
d_ptr->userJobId = job.id();
}
bool ready = true;
# ifdef XMRIG_ALGO_RANDOMX
ready &= d_ptr->initRX();
# endif
# ifdef XMRIG_ALGO_ASTROBWT
ready &= d_ptr->initAstroBWT();
const bool ready = d_ptr->initRX();
# else
constexpr const bool ready = true;
# endif
mutex.unlock();
@ -524,7 +524,7 @@ void xmrig::Miner::onTimer(const Timer *)
const auto printTime = d_ptr->controller->config()->printTime();
if (printTime && d_ptr->ticks && (d_ptr->ticks % (printTime * 2)) == 0) {
printHashrate(false);
d_ptr->printHashrate(false);
}
d_ptr->ticks++;

View file

@ -61,7 +61,6 @@ public:
Job job() const;
void execCommand(char command);
void pause();
void printHashrate(bool details);
void setEnabled(bool enabled);
void setJob(const Job &job, bool donate);
void stop();

View file

@ -28,14 +28,12 @@
#include <cinttypes>
#include "core/config/Config.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/cpu/Cpu.h"
#include "base/io/log/Log.h"
#include "base/kernel/interfaces/IJsonReader.h"
#include "core/config/Config.h"
#include "crypto/common/Assembly.h"
#include "rapidjson/document.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/prettywriter.h"
#ifdef XMRIG_ALGO_RANDOMX

View file

@ -29,11 +29,11 @@
#include <cstdint>
#include "3rdparty/rapidjson/fwd.h"
#include "backend/cpu/CpuConfig.h"
#include "base/kernel/config/BaseConfig.h"
#include "base/tools/Object.h"
#include "core/Benchmark.h"
#include "rapidjson/fwd.h"
namespace xmrig {