Skip to content

Commit

Permalink
NODE-2504 Check genesis generator average and min block time (#3761)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 authored Oct 14, 2022
1 parent 29cd170 commit bfc827b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ object GenesisBlockGenerator {
def inverseCalculateDelay(balance: Long, hitRate: Double): Int =
posCalculator match {
case FairPoSCalculator(minBlockTime, _) =>
val z = (1 - Math.exp((settings.averageBlockDelay.toMillis - minBlockTime) / 70000.0)) * balance
val averageBlockDelay = settings.averageBlockDelay.toMillis
require(
averageBlockDelay > minBlockTime,
s"average-block-delay: ${averageBlockDelay}ms should be > min-block-time: ${minBlockTime}ms"
)
val z = (1 - Math.exp((averageBlockDelay - minBlockTime) / 70000.0)) * balance
(5e17 * (Math.log(hitRate) / z)).toInt
case NxtPoSCalculator =>
(FairPoSCalculator.MaxHit * hitRate / settings.averageBlockDelay.toSeconds / balance).toInt
Expand Down

0 comments on commit bfc827b

Please sign in to comment.