Post
Topic
Board Development & Technical Discussion
Re: Why does the difficulty adjust every 2016 blocks? Why not every block?
by
wabber
on 09/02/2013, 08:49:17 UTC
Well it was said already that the 10mins are the average time needed to find a block. But let me put it in some more understandable analogy.
Think of the difficulty as the sided of a dice. All sides are black except one which is white.
Now you roll the dice, white means you have found a block and black means you didn't.
Let's assume you can only roll the dice once per minute. If the dice has 6 sides you have a chance of 1/6 to find a block every minute. So in average you need 6 minutes to find a block.
But it's also possible that you get the white side on the first try, which means you can also find a block in one minute.

If you are able to somehow increase your speed and you can roll the dice twice a minute now then you would get a block every 3 minutes in average. But if we want the generation time to be constant we need to increase the difficulty which means we take a dice with 12 sides and the generation time is back to 6 minutes in average.

As you can see it's pretty easy to set the difficulty if the global hash rate of the network is known. The problem is that we actually can't know about the hash rate directly, but we do know the elapsed time since the last block was found. Combined with the current difficulty that's enough to calculate the hash rate. But there is a very high error rate. Let's go back to our analogy. Imagine you set the difficulty after every found block(which is what you wanted to know about), then with a dice with 6 sides it's actually pretty common to get the white side on the first try. The Network only knows that we found a block after 1 minute with a difficulty of 6. The Network wants to have a constant rate of 6 minutes per block which is why the difficulty gets adjusted to 36. As you can see the difficulty was multiplied by 6 although our hash rate didn't really change.

The solution for the problem is to average between block generations. If the number of blocks to average is too high, the difficulty will stay on the same level for too long. But if it's too low we will have huge difficulty jumps.

So changing the difficulty after every block would work, but it would be a mess because of the jumping difficulty. However as already said "running averaging" would also be an option. But I think we can agree on that the current system works just fine.