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 ?