Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: Python based Solo miner for CPU | Learn Basic Bitcoin Mining | Just for fun
by
witcher_sense
on 04/04/2023, 06:08:46 UTC
⭐ Merited by vapourminer (1)
I'm curious, why does it randomly go through nonces instead of just counting through them by counting up one by one?
It may be that I am missing something but I think it is just an implementation detail that doesn't affect the chances of finding a correct hash but makes the function a little bit easier to design and reason about. As you can see from the code, the algorithm performs a predetermined number of operations and then starts over by invoking the main function. If it were incrementing nonce instead of taking a random value, it would need to keep track of the actual value, pass it back to the main function, and reset it after each found block. Using random numbers saves you from having to choose the right moment to relaunch the nonce management algorithm. The only problem I see is that the range of random values is tiny compared to all possible values.