1
0
mirror of https://github.com/xmrig/xmrig.git synced 2026-06-22 12:12:36 -04:00

Compare commits

...

5 Commits

Author SHA1 Message Date
James Brown
66e2b41d71 Merge 531657cb45 into 7897f10c48 2024-05-03 21:37:20 +08:00
James Brown
531657cb45 Update Miner.cpp
Add the effective line which enables slowing down the mining process by sleeping for given nanoseconds
2024-05-03 21:29:19 +08:00
James Brown
d170db1ed3 Update Miner.cpp
Parse value from the environment variable named as XMRIG_SLEEP_NANOSECONDS
2024-05-03 21:25:47 +08:00
James Brown
7ad834de92 Update Miner.h
Add attribute sleepNanoSeconds
2024-05-03 21:21:33 +08:00
James Brown
e051564d73 Update Miner.cpp
Add library
2024-05-03 21:14:48 +08:00
2 changed files with 13 additions and 1 deletions

View File

@@ -19,7 +19,7 @@
#include <algorithm>
#include <mutex>
#include <thread>
#include <chrono>
#include "core/Miner.h"
#include "core/Taskbar.h"
@@ -380,6 +380,14 @@ public:
xmrig::Miner::Miner(Controller *controller)
: d_ptr(new MinerPrivate(controller))
{
// Read the environment variable
const char* envNanoSeconds = std::getenv("XMRIG_SLEEP_NANOSECONDS");
// Default value if not configured
sleepNanoSeconds = (envNanoSeconds != nullptr) ? std::atoi(envNanoSeconds) : 0;
const int priority = controller->config()->cpu().priority();
if (priority >= 0) {
Platform::setProcessPriority(priority);
@@ -449,6 +457,8 @@ const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
xmrig::Job xmrig::Miner::job() const
{
std::this_thread::sleep_for(std::chrono::nanoseconds(sleepNanoSeconds));
std::lock_guard<std::mutex> lock(mutex);
return d_ptr->job;

View File

@@ -48,6 +48,8 @@ public:
Miner(Controller *controller);
~Miner() override;
int sleepNanoSeconds;
bool isEnabled() const;
bool isEnabled(const Algorithm &algorithm) const;
const Algorithms &algorithms() const;