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

up vote 4 down vote accepted

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.

  • 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 Mar 1 '17 at 23:18
  • 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 Mar 2 '17 at 10:16
  • I've added the numbers, just in case. – sr-gi Mar 2 '17 at 13:52
  • thank you! I think I got it. Thanks for the explaination. – Roy Kuper Mar 2 '17 at 14:36
  • @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 May 25 '17 at 18:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.