I'm specifically looking for the difficulty retargetting period of Bitcoin Cash, but since it is a fork of Core it should be the same code.
Looks like the answer lies here for bitcoin Cash:
https://reviews.bitcoinabc.org/rABC7ad1105f43d7bff158d4b5c882ab9bf1b74d6cce
More specifically it is here:
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/pow.cpp#L73
-
Just FYI, when you resolve your own question, it is good to accept your answer. Otherwise it gets "bumped" to the front page again and again because the system does not know whether the answer was satisfactory. – Nate Eldredge Jan 28 '18 at 16:15
Albert's link shows the "emergency difficulty adjustment" code. The basic 2016-block difficulty adjustment is defined in chainparams.cpp
:
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60;
This is the desired time in seconds between difficulty adjustments. You can also see below where they hardcode the corresponding number of blocks:
consensus.nMinerConfirmationWindow = 2016;