user58205: I do understand that the mining difficulty changes every 2016 blocks :
next_difficulty = (previous_difficulty * 2016 * 10 minutes) / (time to mine last 2016 blocks)
But how is difficulty changes if suddenly 90% of hash rate disappears* ?
I would be very grateful if someone could kindly point me to the class in sources.
*recent BCH fork had difficulty adjusted quicker than 2016 blocks.
P.S.
Should I be looking at
unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)

in pow.cpp ? 

user48884: 
But how is difficulty changes if suddenly 90% of hash rate disappears* ?

It will change as it normally does, after 2016 blocks. There is no provision for adjusting the difficulty if the hashrate suddenly drops.

*recent BCH fork had difficulty adjusted quicker than 2016 blocks.

As part of their hard fork, they added a provision for cases where blocks are taking too long (i.e. sudden hashrate drop). This extra difficulty changing rule is not present in Bitcoin.

58205: <p>I do understand that the mining difficulty changes every 2016 blocks :</p>

<p>next_difficulty = (previous_difficulty * 2016 * 10 minutes) / (time to mine last 2016 blocks)</p>

<p>But how is difficulty changes if suddenly 90% of hash rate disappears* ?
I would be very grateful if someone could kindly point me to the class in sources.</p>

<p>*recent BCH fork had difficulty adjusted quicker than 2016 blocks.</p>

<p>P.S.
Should I be looking at</p>

<pre><code>unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&amp; params)
</code></pre>

<p>in pow.cpp ? </p>
 48884: <blockquote>
  <p>But how is difficulty changes if suddenly 90% of hash rate disappears* ?</p>
</blockquote>

<p>It will change as it normally does, after 2016 blocks. There is no provision for adjusting the difficulty if the hashrate suddenly drops.</p>

<blockquote>
  <p>*recent BCH fork had difficulty adjusted quicker than 2016 blocks.</p>
</blockquote>

<p>As part of their hard fork, they added a provision for cases where blocks are taking too long (i.e. sudden hashrate drop). This extra difficulty changing rule is not present in Bitcoin.</p>
