Bitcoin mining algorithm
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