Merge branch 'master' into dev

This commit is contained in:
XMRig 2017-07-04 14:56:40 +03:00
commit 68795137da
8 changed files with 135 additions and 30 deletions

View file

@ -2,7 +2,7 @@
XMRig is high performance Monero (XMR) CPU miner, with the official full Windows support.
Based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code.
<img src="http://i.imgur.com/GdRDnAu.png" width="596" >
<img src="https://i.imgur.com/OXoB10D.png" width="628" >
#### Table of contents
* [Features](#features)
@ -38,11 +38,16 @@ Based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of
xmrig.exe -o xmr-eu.dwarfpool.com:8005 -u YOUR_WALLET -p x -k
```
### Failover
```
xmrig.exe -o pool.supportxmr.com:5555 -u YOUR_WALLET1 -k -o xmr-eu.dwarfpool.com:8005 -u YOUR_WALLET2 -p x -k
```
For failover you can add multiple pools, maximum count not limited.
### Options
```
-a, --algo=ALGO cryptonight (default) or cryptonight-lite
-o, --url=URL URL of mining server
-b, --backup-url=URL URL of backup mining server
-O, --userpass=U:P username:password pair for mining server
-u, --user=USERNAME username for mining server
-p, --pass=PASSWORD password for mining server

View file

@ -40,6 +40,6 @@ void Cpu::init()
}
void Cpu::setAffinity(int id, unsigned long mask)
void Cpu::setAffinity(int id, uint64_t mask)
{
}

View file

@ -29,6 +29,9 @@
#include <stdint.h>
#include "Job.h"
class JobResult
{
public:
@ -39,6 +42,16 @@ public:
memcpy(this->result, result, sizeof(this->result));
}
inline JobResult &operator=(const Job &job) {
memcpy(jobId, job.id(), sizeof(jobId));
poolId = job.poolId();
diff = job.diff();
return *this;
}
char jobId[64];
int poolId;
uint32_t diff;

View file

@ -146,6 +146,10 @@ bool Url::setUserpass(const char *userpass)
void Url::setPassword(const char *password)
{
if (!password) {
return;
}
free(m_password);
m_password = strdup(password);
}
@ -153,6 +157,10 @@ void Url::setPassword(const char *password)
void Url::setUser(const char *user)
{
if (!user) {
return;
}
free(m_user);
m_user = strdup(user);
}

View file

@ -30,11 +30,33 @@
#include "workers/Workers.h"
DoubleWorker::DoubleWorker(Handle *handle)
: Worker(handle),
m_nonce1(0),
m_nonce2(0)
class DoubleWorker::State
{
public:
inline State() :
nonce1(0),
nonce2(0)
{}
Job job;
uint32_t nonce1;
uint32_t nonce2;
uint8_t blob[84 * 2];
};
DoubleWorker::DoubleWorker(Handle *handle)
: Worker(handle)
{
m_state = new State();
m_pausedState = new State();
}
DoubleWorker::~DoubleWorker()
{
delete m_state;
delete m_pausedState;
}
@ -56,17 +78,17 @@ void DoubleWorker::start()
}
m_count += 2;
*Job::nonce(m_blob) = ++m_nonce1;
*Job::nonce(m_blob + m_job.size()) = ++m_nonce2;
*Job::nonce(m_state->blob) = ++m_state->nonce1;
*Job::nonce(m_state->blob + m_state->job.size()) = ++m_state->nonce2;
CryptoNight::hash(m_blob, m_job.size(), m_hash, m_ctx);
CryptoNight::hash(m_state->blob, m_state->job.size(), m_hash, m_ctx);
if (*reinterpret_cast<uint64_t*>(m_hash + 24) < m_job.target()) {
Workers::submit(JobResult(m_job.poolId(), m_job.id(), m_nonce1, m_hash, m_job.diff()));
if (*reinterpret_cast<uint64_t*>(m_hash + 24) < m_state->job.target()) {
Workers::submit(JobResult(m_state->job.poolId(), m_state->job.id(), m_state->nonce1, m_hash, m_state->job.diff()));
}
if (*reinterpret_cast<uint64_t*>(m_hash + 32 + 24) < m_job.target()) {
Workers::submit(JobResult(m_job.poolId(), m_job.id(), m_nonce2, m_hash + 32, m_job.diff()));
if (*reinterpret_cast<uint64_t*>(m_hash + 32 + 24) < m_state->job.target()) {
Workers::submit(JobResult(m_state->job.poolId(), m_state->job.id(), m_state->nonce2, m_hash + 32, m_state->job.diff()));
}
std::this_thread::yield();
@ -77,20 +99,46 @@ void DoubleWorker::start()
}
bool DoubleWorker::resume(const Job &job)
{
if (m_state->job.poolId() == -1 && job.poolId() >= 0 && memcmp(job.id(), m_pausedState->job.id(), 64) == 0) {
*m_state = *m_pausedState;
return true;
}
return false;
}
void DoubleWorker::consumeJob()
{
m_job = Workers::job();
Job job = Workers::job();
m_sequence = Workers::sequence();
memcpy(m_blob, m_job.blob(), m_job.size());
memcpy(m_blob + m_job.size(), m_job.blob(), m_job.size());
save(job);
if (m_job.isNicehash()) {
m_nonce1 = (*Job::nonce(m_blob) & 0xff000000U) + (0xffffffU / (m_threads * 2) * m_id);
m_nonce2 = (*Job::nonce(m_blob + m_job.size()) & 0xff000000U) + (0xffffffU / (m_threads * 2) * (m_id + m_threads));
if (resume(job)) {
return;
}
m_state->job = std::move(job);
memcpy(m_state->blob, m_state->job.blob(), m_state->job.size());
memcpy(m_state->blob + m_state->job.size(), m_state->job.blob(), m_state->job.size());
if (m_state->job.isNicehash()) {
m_state->nonce1 = (*Job::nonce(m_state->blob) & 0xff000000U) + (0xffffffU / (m_threads * 2) * m_id);
m_state->nonce2 = (*Job::nonce(m_state->blob + m_state->job.size()) & 0xff000000U) + (0xffffffU / (m_threads * 2) * (m_id + m_threads));
}
else {
m_nonce1 = 0xffffffffU / (m_threads * 2) * m_id;
m_nonce2 = 0xffffffffU / (m_threads * 2) * (m_id + m_threads);
m_state->nonce1 = 0xffffffffU / (m_threads * 2) * m_id;
m_state->nonce2 = 0xffffffffU / (m_threads * 2) * (m_id + m_threads);
}
}
void DoubleWorker::save(const Job &job)
{
if (job.poolId() == -1 && m_state->job.poolId() >= 0) {
*m_pausedState = *m_state;
}
}

View file

@ -38,17 +38,20 @@ class DoubleWorker : public Worker
{
public:
DoubleWorker(Handle *handle);
~DoubleWorker();
void start() override;
private:
bool resume(const Job &job);
void consumeJob();
void save(const Job &job);
class State;
Job m_job;
uint32_t m_nonce1;
uint32_t m_nonce2;
uint8_t m_hash[64];
uint8_t m_blob[84 * 2];
State *m_state;
State *m_pausedState;
};

View file

@ -68,15 +68,32 @@ void SingleWorker::start()
}
bool SingleWorker::resume(const Job &job)
{
if (m_job.poolId() == -1 && job.poolId() >= 0 && memcmp(job.id(), m_paused.id(), 64) == 0) {
m_job = m_paused;
m_result = m_job;
m_result.nonce = *m_job.nonce();
return true;
}
return false;
}
void SingleWorker::consumeJob()
{
m_job = Workers::job();
Job job = Workers::job();
m_sequence = Workers::sequence();
memcpy(m_result.jobId, m_job.id(), sizeof(m_result.jobId));
m_result.poolId = m_job.poolId();
m_result.diff = m_job.diff();
save(job);
if (resume(job)) {
return;
}
m_job = std::move(job);
m_result = m_job;
if (m_job.isNicehash()) {
m_result.nonce = (*m_job.nonce() & 0xff000000U) + (0xffffffU / m_threads * m_id);
@ -85,3 +102,11 @@ void SingleWorker::consumeJob()
m_result.nonce = 0xffffffffU / m_threads * m_id;
}
}
void SingleWorker::save(const Job &job)
{
if (job.poolId() == -1 && m_job.poolId() >= 0) {
m_paused = m_job;
}
}

View file

@ -41,9 +41,12 @@ public:
void start() override;
private:
bool resume(const Job &job);
void consumeJob();
void save(const Job &job);
Job m_job;
Job m_paused;
JobResult m_result;
};