A retargeting algorithm, also referred to as a difficulty adjustment algorithm, is used on proof-of-work blockchains, such as Bitcoin.
Each block on PoW blockchains is created by a miner solving a complex set of equations or puzzles, however, the puzzles get harder and harder to solve after each block. The puzzle is solved by miners varying a nonce (number only used once) that produces a hash value that is lower than the hash target, which is a predefined condition of each block.
Each miner competes with the others to be the first one to solve the puzzle. The first one to solve it will receive a reward of Bitcoin and after the majority of miners reach a consensus, the block will be validated and added to the blockchain.
In order to define the block’s hash value and validate the transaction, miners must use the SHA-256 hashing function until the value is less than the target. If not, they need to keep modifying the nonce and repeat the SHA-256 hashing function until it is.
However, this predefined target is adjusted every 2016 blocks, approximately every 14 days, and is called “retargeting.” Retargeting ensures that the average time it takes to generate a block, 10 minutes, is maintained by increasing the difficulty of the puzzle.
Retargeting is generated by dividing the hash target of the first block by the hash target of the current block. This constant retargeting on PoW blockchains means that more computing power is required by miners today than when Bitcoin was created in 2009.