<p>To make it simple:</p>

<p>Mining consist on finding a specific block that once hashed gives a value bellow a certain threshold (<strong>the target</strong>). </p>

<p>The target is recalculated every fixed amount of blocks (<strong>2016</strong>), so that it is refreshed <strong>every two weeks</strong> (at 1 block per 10 minutes rate). </p>

<p>When recalculated, the <strong>total network hash rate</strong> is taken into account, so that according to that value a block will be mined every ten minutes on average. Notice that this is purely probabilistic. </p>

<p><strong>How does it work?</strong> </p>

<p>The target is a 256-bit value that is reset periodically. When a block is mined, the SHA-256 hash is performed over the block and the result is compared with the target. </p>

<p>Now, if the target is a huge 256-bit number, the hash of the block will be easily smaller than the target, and the block will be considered valid. However, if the target value is really small, finding a valid block will be way harder. Here is where the network hashrate comes into play. The bigger the hashrate, the lower the target. So, once 2016 block have been published since the last update the target will be recalculated, making it higher or lower depending on how the total network hashrate has evolved.</p>

<p>Notice that it could happen indeed that a block is found in less, or more, than the 10 minutes, but the odds are more likely to be around the mark. </p>

<p><strong>How is it calculated?</strong></p>

<p>If you want to know exactly how it is calculated, here you have a Python code that does so: </p>

<pre><code>max_tgt = int("00000000FFFF0000000000000000000000000000000000000000000000000000", 16)  # Around 2^224

current_diff = 440779902287

current_tgt = max_tgt / current_diff  # current_diff = max_tgt/current_tgt

hash_rate = 3310469378 * pow(10, 9)  # GHash/s to Hash/s

print current_tgt/float(pow(2, 256)) * hash_rate * 600
</code></pre>

<p>By dividing the current target by the maximum number of possible hashes (2^256) you get the odds of finding a valid hash. If you multiply this by the hash rate you get how many correct hashes will be get in a second. Finally, by multiplying it by 10 minutes (600 seconds) you get how many valid hashes, on average, you will get in ten minutes.</p>

<p>What gives you:</p>

<pre><code>1.04920216926
</code></pre>

<p>Data such as maximum target (<code>max_tgt</code>), current difficulty (<code>current_diff</code>) and hash rate (<code>hash_rate</code>) has been obtained from <a href="https://bitcoinwisdom.com/bitcoin/difficulty" rel="nofollow noreferrer">bitcoinwisdom</a>, and matches with the current network data. There you can also find some charts about how the hashrate and the difficulty has evolved in the last months. </p>

<p>For those wondering how the network hashrate is actually computed, you can check it in <a href="https://bitcoin.stackexchange.com/questions/11139/how-is-the-network-hash-rate-calculated">this answer.</a></p>

CC BY-SA 3.0
2017-03-01T23:18:37.307Z
Can you give more details about the calculation, and how this calculation makes the mining process to be 10 minutes on average? Becuase again, I don't see why a situatuion of miner who finds a block in a few seconds (For example, Nonce=2 gives him value <= target) is not a common situation? I don't understand how the calculation reducing this situation. Thanks for the help!
Roy Kuper
CC BY-SA 3.0
2017-03-02T10:16:35.010Z
I've extended the explanation. It didn't go down to the numbers to make it simple, however, I can look for the exact formula if you need it.
sr_gi
CC BY-SA 3.0
2017-03-02T13:52:22.717Z
I've added the numbers, just in case.
sr_gi
CC BY-SA 3.0
2017-03-02T14:36:34.300Z
thank you! I think I got it. Thanks for the explaination.
Roy Kuper
CC BY-SA 3.0
2017-05-25T18:22:38.797Z
@sr_gi How does the system know when 2 weeks have passed? I thought the only way to verify time was with a trusted source, which doesn't seem very bitcoiny to me. Are miners trusted to put in accurate timestamps?
B T
CC BY-SA 3.0
2017-05-25T18:31:28.823Z
@BT "Time" is measured in blocks. Since the difficulty is adjusted so the mean block generation time matches with around 10 minutes, 2016 blocks will be mined every two week give or take. (2016 blocks / 6 blocks/hour * 24 hour/day = 14 days)
sr_gi
CC BY-SA 3.0
2017-05-25T18:50:51.560Z
@sr_gi Thanks but you're answering a question I didn't ask. I understand what it adjusts the difficulty to and why it does that. What I don't understand is how the networks measures time in a verified way so it can make that adjustment. How does it know that 2 weeks has passed? Does it use timestamps put in blocks by miners? Or does it use some other mechanism?
B T
CC BY-SA 3.0
2017-05-25T19:02:03.670Z
It doesn't know. The difficulty is adjusted every 2016 blocks, that should match more or less to two weeks. If it actually matches or not, depends on how the network hashrate has evolved though the last update. So ultimately "the network" does not know if once 2016 block has been mined, after the last update, the elapsed time has been two week or not.
sr_gi
CC BY-SA 3.0
2017-05-25T20:51:41.463Z
@sr_gi ok it seems like what you're saying is that time comes out of the hashrate. I can buy that. So how is hashrate calculated?
B T
CC BY-SA 3.0
2017-05-25T21:03:21.260Z
Check this answer from @cdecker: https://bitcoin.stackexchange.com/a/11142/30668. I will update my answer with the link in case anyone else is interested in knowing how.
sr_gi
CC BY-SA 3.0
2017-03-01T22:40:24.503Z
2017-05-25T21:14:32.927Z
2017-05-25T21:14:32.927Z
sr_gi
<p>I don't think that I fully understood the "difficulty" topic in blockchain, and therefore I don't understand how mining process takes close to 10 minutes.</p>

<p>If I have "Target" value (some hash value, which each block's value must be lower or equal to this Target), Why does it take 10 minutes to find hash value for the block? Maybe when the Nonce=2 the value of the block will be &lt;= Target, maybe when the Nonce = 100000000 the value will be &lt;= Target. </p>

<p>But if Nonce = 2 , then the time of the mining is couple of seconds, and if the Nonce = 100000000 , the time of mining is couple of minutes..</p>

<p>So it's a matter of luck or something, but the time of the mining can change.. So what is the principle in the blockchain \ What does miners do, in order to make the mining process in a 10 minutes average?</p>

<p>I'm new to this technology so i would appreciate simple answers 
Thanks in advance</p>

CC BY-SA 3.0
2017-03-01T22:44:25.303Z
What you're describing absolutely does happen. Sometimes we get 30 minutes without a block. Sometimes we get 30 seconds between blocks.
Nick ODell
CC BY-SA 3.0
2017-05-25T21:47:46.110Z
possible duplicate of [What keeps the average block time at 10 minutes?](https://bitcoin.stackexchange.com/q/855/5406), related [How can we be sure that a new block will be found?](https://bitcoin.stackexchange.com/q/22978/5406)
Murch
<mining-theory><difficulty><block-interval>
How does mining process takes Approximately 10 minutes?
Roy Kuper
# How does mining process takes Approximately 10 minutes?

(Asked by: username_0 on 2017-03-01)

I don't think that I fully understood the "difficulty" topic in blockchain, and therefore I don't understand how mining process takes close to 10 minutes.

If I have "Target" value (some hash value, which each block's value must be lower or equal to this Target), Why does it take 10 minutes to find hash value for the block? Maybe when the Nonce=2 the value of the block will be <= Target, maybe when the Nonce = 100000000 the value will be <= Target.

But if Nonce = 2 , then the time of the mining is couple of seconds, and if the Nonce = 100000000 , the time of mining is couple of minutes..

So it's a matter of luck or something, but the time of the mining can change.. So what is the principle in the blockchain \ What does miners do, in order to make the mining process in a 10 minutes average?

I'm new to this technology so i would appreciate simple answers
Thanks in advance

**Tags:** mining-theory, difficulty, block-interval

> **Comments:**
> **username_1**: What you're describing absolutely does happen. Sometimes we get 30 minutes without a block. Sometimes we get 30 seconds between blocks.  
> **username_2**: possible duplicate of [What keeps the average block time at 10 minutes?](https://bitcoin.stackexchange.com/q/855/5406), related [How can we be sure that a new block will be found?](https://bitcoin.stackexchange.com/q/22978/5406)  

---

## 1 answers

### Answer by username_3 on 2017-03-01. Score: 4 | Accepted answer

To make it simple:
Mining consist on finding a specific block that once hashed gives a value bellow a certain threshold (the target). 
The target is recalculated every fixed amount of blocks (2016), so that it is refreshed every two weeks (at 1 block per 10 minutes rate). 
When recalculated, the total network hash rate is taken into account, so that according to that value a block will be mined every ten minutes on average. Notice that this is purely probabilistic. 
How does it work? 
The target is a 256-bit value that is reset periodically. When a block is mined, the SHA-256 hash is performed over the block and the result is compared with the target. 
Now, if the target is a huge 256-bit number, the hash of the block will be easily smaller than the target, and the block will be considered valid. However, if the target value is really small, finding a valid block will be way harder. Here is where the network hashrate comes into play. The bigger the hashrate, the lower the target. So, once 2016 block have been published since the last update the target will be recalculated, making it higher or lower depending on how the total network hashrate has evolved.
Notice that it could happen indeed that a block is found in less, or more, than the 10 minutes, but the odds are more likely to be around the mark. 
How is it calculated?
If you want to know exactly how it is calculated, here you have a Python code that does so: 
max_tgt = int("00000000FFFF0000000000000000000000000000000000000000000000000000", 16)  # Around 2^224

current_diff = 440779902287

current_tgt = max_tgt / current_diff  # current_diff = max_tgt/current_tgt

hash_rate = 3310469378 * pow(10, 9)  # GHash/s to Hash/s

print current_tgt/float(pow(2, 256)) * hash_rate * 600

By dividing the current target by the maximum number of possible hashes (2^256) you get the odds of finding a valid hash. If you multiply this by the hash rate you get how many correct hashes will be get in a second. Finally, by multiplying it by 10 minutes (600 seconds) you get how many valid hashes, on average, you will get in ten minutes.
What gives you:
1.04920216926

Data such as maximum target (max_tgt), current difficulty (current_diff) and hash rate (hash_rate) has been obtained from bitcoinwisdom, and matches with the current network data. There you can also find some charts about how the hashrate and the difficulty has evolved in the last months. 
For those wondering how the network hashrate is actually computed, you can check it in this answer.

> **Comments:**
> **username_0**: Can you give more details about the calculation, and how this calculation makes the mining process to be 10 minutes on average? Becuase again, I don't see why a situatuion of miner who finds a block in a few seconds (For example, Nonce=2 gives him value <= target) is not a common situation? I don't understand how the calculation reducing this situation. Thanks for the help!  
> **username_3**: I've extended the explanation. It didn't go down to the numbers to make it simple, however, I can look for the exact formula if you need it.  
> **username_3**: I've added the numbers, just in case.  
> **username_0**: thank you! I think I got it. Thanks for the explaination.  
> **username_4**: @username_3 How does the system know when 2 weeks have passed? I thought the only way to verify time was with a trusted source, which doesn't seem very bitcoiny to me. Are miners trusted to put in accurate timestamps?  
> **username_3**: @BT "Time" is measured in blocks. Since the difficulty is adjusted so the mean block generation time matches with around 10 minutes, 2016 blocks will be mined every two week give or take. (2016 blocks / 6 blocks/hour * 24 hour/day = 14 days)  
> **username_4**: @username_3 Thanks but you're answering a question I didn't ask. I understand what it adjusts the difficulty to and why it does that. What I don't understand is how the networks measures time in a verified way so it can make that adjustment. How does it know that 2 weeks has passed? Does it use timestamps put in blocks by miners? Or does it use some other mechanism?  
> **username_3**: It doesn't know. The difficulty is adjusted every 2016 blocks, that should match more or less to two weeks. If it actually matches or not, depends on how the network hashrate has evolved though the last update. So ultimately "the network" does not know if once 2016 block has been mined, after the last update, the elapsed time has been two week or not.  
> **username_4**: @username_3 ok it seems like what you're saying is that time comes out of the hashrate. I can buy that. So how is hashrate calculated?  
> **username_3**: Check this answer from @cdecker: https://bitcoin.stackexchange.com/a/11142/30668. I will update my answer with the link in case anyone else is interested in knowing how.  

---

