<p>The data being hashed is constantly updated. The block header contains a time field and is updated every few seconds. If it doesn't timeout and reset (get new work), the algorithm will be working on a stale header.</p>
<p>&quot;When generating, you constantly hash the block header. The block is also occasionally updated as you are working on it.&quot;
<a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Block_hashing_algorithm</a></p>

CC BY-SA 4.0
2013-06-23T01:39:21.630Z
2021-04-08T14:51:23.243Z
2021-04-08T14:51:23.243Z
Joe
<p>Knowing absolutely nothing about how this works, I would hypothesize:</p>

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

CC BY-SA 3.0
2013-05-31T17:05:57.230Z
2013-05-31T17:05:57.230Z
KarmicDebt
<p>I was looking at some sample mining algorithms and also some sample code and there was something which I didnt really understand. In <a href="https://bitcoin.stackexchange.com/questions/3044/simple-bitcoin-mining-algorithm/3047#3047">Simple bitcoin mining algorithm</a> he says ,
The simplest miner would work like this:</p>

<pre><code>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&lt;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
</code></pre>

<p>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:</p>

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

<mining-technical-details><mining-software><fpga><open-source>
Bitcoin mining algorithm
Enthusiast
# Bitcoin mining algorithm

(Asked by: username_0 on 2013-05-31)

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](https://bitcoin.stackexchange.com/questions/3044/simple-bitcoin-mining-algorithm/3047#3047) 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

**Tags:** mining-technical-details, mining-software, fpga, open-source


---

## 2 answers

### Answer by username_1 on 2013-06-23. Score: 2

The data being hashed is constantly updated. The block header contains a time field and is 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>


---

### Answer by username_2 on 2013-05-31. Score: 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


---

