Integrated thread based double hash mode
This commit is contained in:
parent
db91ccb1f4
commit
0712d269ef
17 changed files with 161 additions and 134 deletions
|
@ -82,17 +82,18 @@ void DoubleWorker::start()
|
|||
}
|
||||
|
||||
m_count += 2;
|
||||
|
||||
*Job::nonce(m_state->blob) = ++m_state->nonce1;
|
||||
*Job::nonce(m_state->blob + m_state->job.size()) = ++m_state->nonce2;
|
||||
|
||||
CryptoNight::hash(m_state->blob, m_state->job.size(), m_hash, m_ctx);
|
||||
CryptoNight::hashDouble(m_state->blob, m_state->job.size(), m_hash, m_ctx);
|
||||
|
||||
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()));
|
||||
Workers::submit(JobResult(m_state->job.poolId(), m_state->job.id(), m_state->nonce1, m_hash, m_state->job.diff()), m_id);
|
||||
}
|
||||
|
||||
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()));
|
||||
Workers::submit(JobResult(m_state->job.poolId(), m_state->job.id(), m_state->nonce2, m_hash + 32, m_state->job.diff()), m_id);
|
||||
}
|
||||
|
||||
std::this_thread::yield();
|
||||
|
|
|
@ -60,8 +60,10 @@ void SingleWorker::start()
|
|||
m_count++;
|
||||
*m_job.nonce() = ++m_result.nonce;
|
||||
|
||||
if (CryptoNight::hash(m_job, m_result, m_ctx)) {
|
||||
Workers::submit(m_result);
|
||||
CryptoNight::hash(m_job.blob(), m_job.size(), m_result.result, m_ctx);
|
||||
|
||||
if (*reinterpret_cast<uint64_t*>(m_result.result + 24) < m_job.target()) {
|
||||
Workers::submit(m_result, m_id);
|
||||
}
|
||||
|
||||
std::this_thread::yield();
|
||||
|
@ -103,10 +105,10 @@ void SingleWorker::consumeJob()
|
|||
m_result = m_job;
|
||||
|
||||
if (m_job.isNicehash()) {
|
||||
m_result.nonce = (*m_job.nonce() & 0xff000000U) + (0xffffffU / m_threads * m_id);
|
||||
m_result.nonce = (*m_job.nonce() & 0xff000000U) + (0xffffffU / (m_threads * 2) * m_id);
|
||||
}
|
||||
else {
|
||||
m_result.nonce = 0xffffffffU / m_threads * m_id;
|
||||
m_result.nonce = 0xffffffffU / (m_threads * 2) * m_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ void Workers::stop()
|
|||
}
|
||||
|
||||
|
||||
void Workers::submit(const JobResult &result)
|
||||
void Workers::submit(const JobResult &result, int threadId)
|
||||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
m_queue.push_back(result);
|
||||
|
@ -153,7 +153,7 @@ void Workers::submit(const JobResult &result)
|
|||
void Workers::onReady(void *arg)
|
||||
{
|
||||
auto handle = static_cast<Handle*>(arg);
|
||||
if (Mem::isDoubleHash()) {
|
||||
if (Mem::isDoubleHash(handle->threadId())) {
|
||||
handle->setWorker(new DoubleWorker(handle));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
static void setJob(const Job &job);
|
||||
static void start(int64_t affinity, int priority);
|
||||
static void stop();
|
||||
static void submit(const JobResult &result);
|
||||
static void submit(const JobResult &result, int threadId);
|
||||
|
||||
static inline bool isEnabled() { return m_enabled; }
|
||||
static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue