Custom nonce trying strategy
Mouradif opened this issue · 6 comments
I was thinking, when trying out nonces, if everyone starts with 0 and increments, then the faster computer will ALWAYS get a valid nonce before all the others. So I wanted to change that nonce trying strategy on the version I'm running, thinking maybe I can find a working nonce that other nodes wouldn't try until late.
I've been trying to read through cpu-miner.c
but without much success. If I wanted for example to start from the max value and decrement the nonce for each try how would I do that?
Here's what I tried, I have the feeling something is off because I don't see the process using all the CPU like it used to:
diff --git a/cpu-miner.c b/cpu-miner.c
index ef2fc76..d14af92 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -1193,9 +1193,9 @@ static void *miner_thread(void *userdata)
if (memcmp(work.data, g_work.data, 76)) {
work_free(&work);
work_copy(&work, &g_work);
- work.data[19] = 0xffffffffU / opt_n_threads * thr_id;
+ work.data[19] = 0xffffffffU / opt_n_threads * (thr_id + 1);
} else
- work.data[19]++;
+ work.data[19]--;
pthread_mutex_unlock(&g_work_lock);
work_restart[thr_id].restart = 0;
I was thinking, when trying out nonces, if everyone starts with 0 and increments, then the faster computer will ALWAYS get a valid nonce before all the others.
No, you've fallen into a common fallacy. Mining servers provide each client with unique work, so there is no direct competition among miners.
When you say mining servers you mean pools ? What if I'm solo mining ?
When you say mining servers you mean pools ? What if I'm solo mining ?
I mean any kind of server the miner gets its work from. To mine solo you probably told cpuminer to connect to a local coin daemon; that would be your mining server.
Understood! Thanks!
I got thrown off by this answer of yours : #183 (comment)
This may not be the right place but if you would kindly explain the difference that would help a lot
The nonce is not the only thing that can be changed in a block header to make it different. In particular, servers make sure that each miner works on a different Merkle root hash.