diff --git a/src/pow.ts b/src/pow.ts index 2e89f08..dbd594b 100644 --- a/src/pow.ts +++ b/src/pow.ts @@ -14,11 +14,13 @@ const determineDifficulty = () => { const determineChallengesNeeded = (amount: number, usedCaptcha: boolean) => { const { MIN_TEZ, MAX_TEZ, MIN_CHALLENGES, MAX_CHALLENGES, MAX_CHALLENGES_WITH_CAPTCHA } = env - // Calculate the proportion of the requested Tez to the maximum Tez - const tezProportion = (amount - MIN_TEZ) / (MAX_TEZ - MIN_TEZ) - // Calculate the base number of challenges based on the Tez proportion and whether a captcha was used const maxChallenges = usedCaptcha ? MAX_CHALLENGES_WITH_CAPTCHA : MAX_CHALLENGES + + if (MIN_TEZ === MAX_TEZ) return maxChallenges + + // Calculate the proportion of the requested Tez to the maximum Tez + const tezProportion = (amount - MIN_TEZ) / (MAX_TEZ - MIN_TEZ) const challengesNeeded = Math.ceil(tezProportion * (maxChallenges - MIN_CHALLENGES) + MIN_CHALLENGES) return challengesNeeded