more flexible calcDifficulty

This commit is contained in:
andri lim 2019-09-04 13:36:48 +07:00 committed by zah
parent 081baa6da7
commit a1c21722dd
1 changed files with 11 additions and 0 deletions

View File

@ -149,3 +149,14 @@ func calcDifficulty*(timeStamp: EthTime, parent: BlockHeader): DifficultyInt =
result = calcDifficultyHomestead(timeStamp, parent)
else:
result = calcDifficultyFrontier(timeStamp, parent)
func calcDifficulty*(timeStamp: EthTime, parent: BlockHeader, fork: Fork): DifficultyInt =
case fork
of FkConstantinople:
result = calcDifficultyConstantinople(timeStamp, parent)
of FkByzantium:
result = calcDifficultyByzantium(timeStamp, parent)
of FkHomestead..FkSpurious:
result = calcDifficultyHomestead(timeStamp, parent)
else:
result = calcDifficultyFrontier(timeStamp, parent)