<p>They were never "waiting" in the first place.</p>

<p>A miner is incrementing nonces and computing hashes continuously.  As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header.</p>

<p>It's misleading to call this a "restart", since that implies there was some progress that is being lost.  Mining is progress-free.  Each hash is an independent trial with equal probability to succeed, regardless of what the underlying block header is.</p>

<p>To emphasize this, suppose you have a block header h1 on which you have already tried a billion nonce values, and a header h2 which has just been generated and on which no nonces have been tried yet.  If you have the choice as to which one to hash next, which should you choose, for the greatest chance of finding a winning nonce?  The answer is, it makes no difference - they both have exactly the same probability.  So there is no harm in switching to h2.</p>

CC BY-SA 3.0
2016-11-09T06:46:18.423Z
Thank you very much Nate for you answer! I have another question related to this: so every time a correct nonce number is found which helps to mine a new block and the process of creating new block starts again, the "variable" (if any) which represents the current trial nonce will be initialized to zero for the new round or it will keep the value where it has ended in the previous round?
hoanghs13
CC BY-SA 3.0
2016-11-09T08:52:44.677Z
It does not matter - all what matters is that the nonce changes. In fact, modern hardware mining boxes cycle through all nonces for a block candidate in under a millisecond, so they are continuously trying other variations in the block as well.
Pieter Wuille
CC BY-SA 3.0
2016-11-09T13:02:33.040Z
@hoanghs13: I believe Bitcoin Core resets the nonce to zero.  This happens to be convenient because it makes it easy to check when you have gone through all 2^32 nonce values for a particular block header.  But there is nothing magical about this, and software that chose to start at a different value, or a random value, would work just the same.
Nate Eldredge
CC BY-SA 3.0
2016-11-09T18:17:45.057Z
Typical modern mining hardware always tries all possible nonces. There's no point in wasting precious ASIC space on doing anything else. Essentially, the operation the ASIC performs efficiently is that of trying all 2^32 possible nonces.
David Schwartz
CC BY-SA 3.0
2016-11-09T04:34:33.800Z
2016-11-09T04:34:33.800Z
Nate Eldredge
<p>I know my question might sound familiar to the question as follow:
<a href="https://bitcoin.stackexchange.com/questions/40398/when-does-a-miner-decide-to-stop-collecting-transactions-and-start-calculating-h">When does a miner decide to stop collecting transactions and start calculating hashes to try to win?</a></p>

<p>But actually, the reply marked as answer in that topic didn't answer the question: <strong>when will miners stop waiting/listening to new transactions</strong>?</p>

<p>According the answer in the link above, miners will start calculating nonce number but as far as I know, the nonce number is result of hash calculation of block header. Since the block header contains the hash of the merkle tree's root which is generated by all the transactions included in the block, so waiting and adding new transactions means the hash of the merkle tree's root will keep changing so <strong>how can miners determine to stop and concentrate in 'mining' the nonce from a stable source of transactions (or merkle tree's root hash)</strong>? </p>

<p>Let's simplify the questions by an example in case you cannot understand my language: miner A receives transaction a1 and then start calculating the nonce number for 1 minute (let's assume that in this period of time, there's no new transactions come and interrupt the process) but then a transaction a2 arrives, what will miner A do? Adding a2 into the candidate block, getting new hash of merkle tree's root and restarting to find the nonce number? Or just ignore the transaction a2? If A chooses to ignore new transactions to be included, can anybody tell me when it will do that (assume all of the transactions collected are not larger than the MAX_BLOCK_SIZE constant)?</p>

<p>Any replies or explainations for some of my questions are highly appreciated. Thank you!!</p>

<nonce><merkle-tree>
When do miners stop waiting for new transactions?
hoanghs13
# When do miners stop waiting for new transactions?

(Asked by: username_0 on 2016-11-09)

I know my question might sound familiar to the question as follow:
[When does a miner decide to stop collecting transactions and start calculating hashes to try to win?](https://bitcoin.stackexchange.com/questions/40398/when-does-a-miner-decide-to-stop-collecting-transactions-and-start-calculating-h)

But actually, the reply marked as answer in that topic didn't answer the question: **when will miners stop waiting/listening to new transactions**?

According the answer in the link above, miners will start calculating nonce number but as far as I know, the nonce number is result of hash calculation of block header. Since the block header contains the hash of the merkle tree's root which is generated by all the transactions included in the block, so waiting and adding new transactions means the hash of the merkle tree's root will keep changing so **how can miners determine to stop and concentrate in 'mining' the nonce from a stable source of transactions (or merkle tree's root hash)**?

Let's simplify the questions by an example in case you cannot understand my language: miner A receives transaction a1 and then start calculating the nonce number for 1 minute (let's assume that in this period of time, there's no new transactions come and interrupt the process) but then a transaction a2 arrives, what will miner A do? Adding a2 into the candidate block, getting new hash of merkle tree's root and restarting to find the nonce number? Or just ignore the transaction a2? If A chooses to ignore new transactions to be included, can anybody tell me when it will do that (assume all of the transactions collected are not larger than the MAX\_BLOCK\_SIZE constant)?

Any replies or explainations for some of my questions are highly appreciated. Thank you!!

**Tags:** nonce, merkle-tree


---

## 1 answers

### Answer by username_1 on 2016-11-09. Score: 6 | Accepted answer

They were never "waiting" in the first place.

A miner is incrementing nonces and computing hashes continuously. As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header.

It's misleading to call this a "restart", since that implies there was some progress that is being lost. Mining is progress-free. Each hash is an independent trial with equal probability to succeed, regardless of what the underlying block header is.

To emphasize this, suppose you have a block header h1 on which you have already tried a billion nonce values, and a header h2 which has just been generated and on which no nonces have been tried yet. If you have the choice as to which one to hash next, which should you choose, for the greatest chance of finding a winning nonce? The answer is, it makes no difference - they both have exactly the same probability. So there is no harm in switching to h2.

> **Comments:**
> **username_0**: Thank you very much username_1 for you answer! I have another question related to this: so every time a correct nonce number is found which helps to mine a new block and the process of creating new block starts again, the "variable" (if any) which represents the current trial nonce will be initialized to zero for the new round or it will keep the value where it has ended in the previous round?  
> **username_2**: It does not matter - all what matters is that the nonce changes. In fact, modern hardware mining boxes cycle through all nonces for a block candidate in under a millisecond, so they are continuously trying other variations in the block as well.  
> **username_1**: @username_0: I believe Bitcoin Core resets the nonce to zero.  This happens to be convenient because it makes it easy to check when you have gone through all 2^32 nonce values for a particular block header.  But there is nothing magical about this, and software that chose to start at a different value, or a random value, would work just the same.  
> **username_3**: Typical modern mining hardware always tries all possible nonces. There's no point in wasting precious ASIC space on doing anything else. Essentially, the operation the ASIC performs efficiently is that of trying all 2^32 possible nonces.  

---

