mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-16 16:42:14 +00:00
Merge branch 'dev'
This commit is contained in:
commit
ad7c925a1a
9 changed files with 43 additions and 12 deletions
|
@ -534,9 +534,3 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
|
||||||
client->connect(res->ai_addr);
|
client->connect(res->ai_addr);
|
||||||
uv_freeaddrinfo(res);
|
uv_freeaddrinfo(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Client *Client::getClient(void *data)
|
|
||||||
{
|
|
||||||
return static_cast<Client*>(data);
|
|
||||||
}
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ private:
|
||||||
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
||||||
static void onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res);
|
static void onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res);
|
||||||
|
|
||||||
static Client *getClient(void *data);
|
static inline Client *getClient(void *data) { return static_cast<Client*>(data); }
|
||||||
|
|
||||||
bool m_quiet;
|
bool m_quiet;
|
||||||
char m_ip[17];
|
char m_ip[17];
|
||||||
|
|
|
@ -164,3 +164,9 @@ void Job::toHex(const unsigned char* in, unsigned int len, char* out)
|
||||||
out[i * 2 + 1] = hf_bin2hex(in[i] & 0x0F);
|
out[i * 2 + 1] = hf_bin2hex(in[i] & 0x0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Job::operator==(const Job &other) const
|
||||||
|
{
|
||||||
|
return memcmp(m_id, other.m_id, sizeof(m_id)) == 0;
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
static inline uint64_t toDiff(uint64_t target) { return 0xFFFFFFFFFFFFFFFFULL / target; }
|
static inline uint64_t toDiff(uint64_t target) { return 0xFFFFFFFFFFFFFFFFULL / target; }
|
||||||
static void toHex(const unsigned char* in, unsigned int len, char* out);
|
static void toHex(const unsigned char* in, unsigned int len, char* out);
|
||||||
|
|
||||||
|
bool operator==(const Job &other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_nicehash;
|
bool m_nicehash;
|
||||||
int m_poolId;
|
int m_poolId;
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
#include "interfaces/IClientListener.h"
|
|
||||||
#include "interfaces/IJobResultListener.h"
|
#include "interfaces/IJobResultListener.h"
|
||||||
#include "interfaces/IStrategyListener.h"
|
#include "interfaces/IStrategyListener.h"
|
||||||
|
|
||||||
|
@ -57,10 +56,7 @@ protected:
|
||||||
void onResultAccepted(Client *client, uint32_t diff, uint64_t ms, const char *error) override;
|
void onResultAccepted(Client *client, uint32_t diff, uint64_t ms, const char *error) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addPool(const Url *url);
|
|
||||||
void setJob(Client *client, const Job &job);
|
void setJob(Client *client, const Job &job);
|
||||||
void startDonate();
|
|
||||||
void stopDonate();
|
|
||||||
|
|
||||||
bool m_donateActive;
|
bool m_donateActive;
|
||||||
char *m_agent;
|
char *m_agent;
|
||||||
|
|
|
@ -114,6 +114,9 @@ void DoubleWorker::consumeJob()
|
||||||
{
|
{
|
||||||
Job job = Workers::job();
|
Job job = Workers::job();
|
||||||
m_sequence = Workers::sequence();
|
m_sequence = Workers::sequence();
|
||||||
|
if (m_state->job == job) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
save(job);
|
save(job);
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,9 @@ void SingleWorker::consumeJob()
|
||||||
{
|
{
|
||||||
Job job = Workers::job();
|
Job job = Workers::job();
|
||||||
m_sequence = Workers::sequence();
|
m_sequence = Workers::sequence();
|
||||||
|
if (m_job == job) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
save(job);
|
save(job);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include "workers/Workers.h"
|
#include "workers/Workers.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool Workers::m_active = false;
|
||||||
|
bool Workers::m_enabled = true;
|
||||||
Hashrate *Workers::m_hashrate = nullptr;
|
Hashrate *Workers::m_hashrate = nullptr;
|
||||||
IJobResultListener *Workers::m_listener = nullptr;
|
IJobResultListener *Workers::m_listener = nullptr;
|
||||||
Job Workers::m_job;
|
Job Workers::m_job;
|
||||||
|
@ -58,12 +60,33 @@ Job Workers::job()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Workers::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (m_enabled == enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_enabled = enabled;
|
||||||
|
if (!m_active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_paused = enabled ? 0 : 1;
|
||||||
|
m_sequence++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Workers::setJob(const Job &job)
|
void Workers::setJob(const Job &job)
|
||||||
{
|
{
|
||||||
uv_rwlock_wrlock(&m_rwlock);
|
uv_rwlock_wrlock(&m_rwlock);
|
||||||
m_job = job;
|
m_job = job;
|
||||||
uv_rwlock_wrunlock(&m_rwlock);
|
uv_rwlock_wrunlock(&m_rwlock);
|
||||||
|
|
||||||
|
m_active = true;
|
||||||
|
if (!m_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_sequence++;
|
m_sequence++;
|
||||||
m_paused = 0;
|
m_paused = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,14 +43,16 @@ class Workers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Job job();
|
static Job job();
|
||||||
|
static void setEnabled(bool enabled);
|
||||||
static void setJob(const Job &job);
|
static void setJob(const Job &job);
|
||||||
static void start(int64_t affinity);
|
static void start(int64_t affinity);
|
||||||
static void submit(const JobResult &result);
|
static void submit(const JobResult &result);
|
||||||
|
|
||||||
|
static inline bool isEnabled() { return m_enabled; }
|
||||||
static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; }
|
static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; }
|
||||||
static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed) == 1; }
|
static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed) == 1; }
|
||||||
static inline uint64_t sequence() { return m_sequence.load(std::memory_order_relaxed); }
|
static inline uint64_t sequence() { return m_sequence.load(std::memory_order_relaxed); }
|
||||||
static inline void pause() { m_paused = 1; m_sequence++; }
|
static inline void pause() { m_active = false; m_paused = 1; m_sequence++; }
|
||||||
static inline void setListener(IJobResultListener *listener) { m_listener = listener; }
|
static inline void setListener(IJobResultListener *listener) { m_listener = listener; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -58,6 +60,8 @@ private:
|
||||||
static void onResult(uv_async_t *handle);
|
static void onResult(uv_async_t *handle);
|
||||||
static void onTick(uv_timer_t *handle);
|
static void onTick(uv_timer_t *handle);
|
||||||
|
|
||||||
|
static bool m_active;
|
||||||
|
static bool m_enabled;
|
||||||
static Hashrate *m_hashrate;
|
static Hashrate *m_hashrate;
|
||||||
static IJobResultListener *m_listener;
|
static IJobResultListener *m_listener;
|
||||||
static Job m_job;
|
static Job m_job;
|
||||||
|
|
Loading…
Reference in a new issue