Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: What's the rationale behind difficulty adjustment after every 2016 blocks?
by
kxwhalexk
on 03/07/2021, 07:20:18 UTC
⭐ Merited by pooya87 (1)
I was curious about knowing why difficulty adjustment happens every 2016 blocks and not 2 times less (1008 blocks) or 2 times more (4,032 blocks) or even just some random number like 3000 blocks?
If you chose a really shorter distance between difficulty adjustments, like every 100 blocks, you wouldn't estimate the hashrate properly. Take China as an example; the hashrate dropped by 69% within 1-3 days, but the difficulty won't be reduced that much. And it, indeed, shouldn't. That drop is clearly temporary. Once they setup their mining rigs again, the estimation for the last 2016 blocks would be properer than the last 100.

The number “2016” was Satoshi's decision. Another one could have set it to “2000” or “1008”.
Code:
   
    if (nActualTimespan < nTargetTimespan/4)
        nActualTimespan = nTargetTimespan/4;
    if (nActualTimespan > nTargetTimespan*4)
        nActualTimespan = nTargetTimespan*4;

Yes, the next difficulty adjustment range is 1/4--4 times the previous difficulty,There is a maximum adjustment and minimum adjustment limit.