From 6b861808f228eee4f5d9878a02d443b0b78f357a Mon Sep 17 00:00:00 2001 From: Fusl Date: Thu, 27 Jul 2017 04:08:09 +0200 Subject: [PATCH] Produce better pseudo-random numbers for nonce shuffling --- src/workers/SingleWorker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workers/SingleWorker.cpp b/src/workers/SingleWorker.cpp index 47a277d7..801fd5e4 100644 --- a/src/workers/SingleWorker.cpp +++ b/src/workers/SingleWorker.cpp @@ -23,6 +23,7 @@ #include +#include #include "crypto/CryptoNight.h" @@ -38,6 +39,7 @@ SingleWorker::SingleWorker(Handle *handle) void SingleWorker::start() { + srand(getpid() * time(NULL)); bool israndnonce = false; while (Workers::sequence() > 0) { if (Workers::isPaused()) { @@ -60,7 +62,7 @@ void SingleWorker::start() m_count++; if (israndnonce && (m_count & 0xFF) == 0) { - *m_job.nonce() = m_result.nonce += rand(); + *m_job.nonce() = m_result.nonce += (rand() + time(NULL) + getpid()); } else { *m_job.nonce() = ++m_result.nonce; }