<p>It is not the looping that is difficult, it is generating a hash for each iteration of that loop.  Furthermore, as @Nate pointed it, a miner will likely have to change more than just the nonce.  As more transactions are coming in from the network, a miner will add/swap them into the block they are hashing, presumably based on maximizing transaction fees.  Each time the transaction set is modified, all tried nonces can be tried again.</p>

<p>As for why it gets more difficult over time, that is a core part of the protocol.  Every 2,016 blocks, the target hash re-adjusts so that blocks will take about 10 minutes.  As more hashing power enters the network, the faster blocks are found, which in turn will trigger the re-adjustment after 2,016 blocks.</p>

CC BY-SA 3.0
2017-08-31T17:41:56.130Z
You say the target Hash readjusts every 2016 blocks, is that 2016 transactions on the network? And: readjusted how? as in: recalculated so all the previously calculated nounces need to be retried?
Pol
CC BY-SA 3.0
2017-08-31T18:39:43.593Z
@Pol, if you are confused about a block vs a transaction,  it's going to be hard for anyone to give you a satisfactory answer to your question.  I recommend reading up a bit more.  Here's a great place to start, and should give you the context you need to understand these answers:  https://bitcoin.stackexchange.com/questions/148/what-exactly-is-mining
Jestin
CC BY-SA 3.0
2017-08-31T20:52:15.740Z
Agreed, plus there is a question that matches my concerns already. Thanks for your help.
Pol
CC BY-SA 3.0
2017-08-31T16:49:52.920Z
2017-08-31T16:49:52.920Z
Jestin
<p>I'm learning about mining and the first thing that surprised me is that the nounce part of the algorithm which is supposed to be randomly looped until you get a number smaller than the target hash .. is just 32 bits long. Can you explain why then is it so difficult to loop an unsigned int and how come is it increasingly difficult over time? Thank you.</p>

<p>Edit: It's been suggested this is a duplicate, this is not. The other question asked if you could run out of nounces, that's nothing to do with my question. My question is about the difficulty of Hashing the exact same 4 billion unsigned int entry loops.</p>

CC BY-SA 3.0
2017-08-31T13:47:05.657Z
Short answer: With high probability, none of those 2^32 nonces will result in a hash smaller than the target.  So then you change something else in the block header and try again.  For instance, you can increment a number in the coinbase transaction, which results in a new value for the "Merkle root" hash in the block header.  The smaller the target, the more times you are likely to have to do this before success.
Nate Eldredge
CC BY-SA 3.0
2017-08-31T17:48:26.187Z
@NateEldredge It looks like you are saying that you do not really need  to change the nounce since there is the possibility that none of the 4 billion different values may lead to a winning hash. What makes then a valid 'source material' to hash while attemting to discover a right answer? if you can point me to updated literature about it I will accept that as a right answer. Thanks
Pol
CC BY-SA 3.0
2017-08-31T18:08:25.467Z
No, I'm not saying that.  What you need is a valid 80-byte block header whose hash is below the target value.  So you have to keep changing things in the header until you find something that leads to a winning hash. The easiest thing to change is the nonce, so you fix everything else and then try all possible nonces.  If you are lucky then one of them works and you win.  If not, which happens most of the time, then you change something else in the header and try all nonces for the updated header. Repeat indefinitely until you win.
Nate Eldredge
CC BY-SA 3.0
2017-08-31T18:09:05.533Z
There isn't any need for "updated" literature; the block format and hashing algorithm hasn't changed in any relevant way since the initial introduction of Bitcoin.  It was always possible that, with everything else in the header fixed, none of the 2^32 possible nonces wins, and this case always had to be handled; it already happens about 36% of the time even at minimum difficulty.
Nate Eldredge
<hash><mining-reward><sha256><algorithms>
if a Bitcoin mining nounce is just 32 bits long how come is it increasingly difficult to find the winning hash?
Pol
# if a Bitcoin mining nounce is just 32 bits long how come is it increasingly difficult to find the winning hash?

(Asked by: username_0 on 2017-08-31)

I'm learning about mining and the first thing that surprised me is that the nounce part of the algorithm which is supposed to be randomly looped until you get a number smaller than the target hash .. is just 32 bits long. Can you explain why then is it so difficult to loop an unsigned int and how come is it increasingly difficult over time? Thank you.

Edit: It's been suggested this is a duplicate, this is not. The other question asked if you could run out of nounces, that's nothing to do with my question. My question is about the difficulty of Hashing the exact same 4 billion unsigned int entry loops.

**Tags:** hash, mining-reward, sha256, algorithms

> **Comments:**
> **username_1**: Short answer: With high probability, none of those 2^32 nonces will result in a hash smaller than the target.  So then you change something else in the block header and try again.  For instance, you can increment a number in the coinbase transaction, which results in a new value for the "Merkle root" hash in the block header.  The smaller the target, the more times you are likely to have to do this before success.  
> **username_0**: @username_1 It looks like you are saying that you do not really need  to change the nounce since there is the possibility that none of the 4 billion different values may lead to a winning hash. What makes then a valid 'source material' to hash while attemting to discover a right answer? if you can point me to updated literature about it I will accept that as a right answer. Thanks  
> **username_1**: No, I'm not saying that.  What you need is a valid 80-byte block header whose hash is below the target value.  So you have to keep changing things in the header until you find something that leads to a winning hash. The easiest thing to change is the nonce, so you fix everything else and then try all possible nonces.  If you are lucky then one of them works and you win.  If not, which happens most of the time, then you change something else in the header and try all nonces for the updated header. Repeat indefinitely until you win.  
> **username_1**: There isn't any need for "updated" literature; the block format and hashing algorithm hasn't changed in any relevant way since the initial introduction of Bitcoin.  It was always possible that, with everything else in the header fixed, none of the 2^32 possible nonces wins, and this case always had to be handled; it already happens about 36% of the time even at minimum difficulty.  

---

## 1 answers

### Answer by username_2 on 2017-08-31. Score: 0 | Accepted answer

It is not the looping that is difficult, it is generating a hash for each iteration of that loop. Furthermore, as @username_1 pointed it, a miner will likely have to change more than just the nonce. As more transactions are coming in from the network, a miner will add/swap them into the block they are hashing, presumably based on maximizing transaction fees. Each time the transaction set is modified, all tried nonces can be tried again.

As for why it gets more difficult over time, that is a core part of the protocol. Every 2,016 blocks, the target hash re-adjusts so that blocks will take about 10 minutes. As more hashing power enters the network, the faster blocks are found, which in turn will trigger the re-adjustment after 2,016 blocks.

> **Comments:**
> **username_0**: You say the target Hash readjusts every 2016 blocks, is that 2016 transactions on the network? And: readjusted how? as in: recalculated so all the previously calculated nounces need to be retried?  
> **username_2**: @username_0, if you are confused about a block vs a transaction,  it's going to be hard for anyone to give you a satisfactory answer to your question.  I recommend reading up a bit more.  Here's a great place to start, and should give you the context you need to understand these answers:  https://bitcoin.stackexchange.com/questions/148/what-exactly-is-mining  
> **username_0**: Agreed, plus there is a question that matches my concerns already. Thanks for your help.  

---

