3

I was looking at some sample mining algorithms and also some sample code and there was something which I didnt really understand. In Simple bitcoin mining algorithm he says , The simplest miner would work like this:

The simplest miner would work like this:

     1. Request a new [Getwork][1] from a given pool/bitcoind with specified credentials
     2. For nonce=0;nonce<0xFFFFFFFF;nonce++
     - Set Getwork Data nonce
     - SHA-256 hash the Getwork Data ([block header][2])
     - Check if hash result is smaller than Getwork Target, if so, submit a share
     - If more than 1 second passed since you received Getwork, stop the loop
     3. GOTO: 1

What I dont understand is step 2, part 4. Lets consider the above script is connected to an FPGA through a uart port. Wont I wait until the FPGA actually finds a valid nonce and submits the none through the UART line? Why would I exit out of the loop after 1 second and then go through the entire process again. This doesnt make sense to me because then the fpga has only a few seconds to increment the nonce for the given work and it then moves on to the next piece of work? How is this even realistic since even if the same work is submitted again it will go through the same loop and will end up doing nothing productive. What error am I making here? Sample code that I am talking about:

https://github.com/progranism/Open-Source-FPGA-Bitcoin-Miner/blob/master/projects/Verilog_Xilinx_Port/sources/software/miner.py does the same thing. It says golden.wait(timeout) instead of just calling golden.wait() and blocking till a nonce is found

2

The data that is being hashed is constantly being updated. The block header contains a time field and updated every few seconds. If it doesn't timeout and reset (get new work) the algorithm will be working on a stale header.

"When generating, you constantly hash the block header. The block is also occasionally updated as you are working on it" https://en.bitcoin.it/wiki/Block_hashing_algorithm

1

Knowing absolutely nothing about how this works, I would hypothesize:

  • that others get the same work
  • the longer you chew on the data, the higher the probability someone else has already solved the problem
  • even if this is waiting on the network on each iteration, it starts the 1-second timer after getting the work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.