Created
May 13, 2021 07:00
-
-
Save bluepnume/54cfd926f53a5c1e3dbe5995f91f4f38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calculateNewDifficulty = (headBlock : BlockType, previousHeadBlock : ?BlockType) : number => { | |
if (!previousHeadBlock) { | |
return headBlock.difficulty; | |
} | |
return (headBlock.time - previousHeadBlock.time) > BLOCK_TIME | |
? headBlock.difficulty - 1 | |
: headBlock.difficulty + 1; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment