Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1997 from LiskHQ/1996-indexing-failing-due-to-zer…
Browse files Browse the repository at this point in the history
…o-self-stake

Indexing failing due to zero self stake
  • Loading branch information
nagdahimanshu authored Dec 20, 2023
2 parents c583a20 + a5b10f1 commit f9c9ac7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/blockchain-indexer/shared/indexer/utils/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const calcSelfStakeReward = async (generatorAddress, blockReward, commissionAmou
{ amount: BigInt('0') },
);

// Return commission as 0 if total stake is 0. Skip further calculations to avoid division by zero
if (totalStakes <= BigInt('0')) {
return BigInt('0');
}

const selfStakesQ = q96(selfStakes);
const totalStakesQ = q96(totalStakes);
const blockRewardQ = q96(blockReward);
Expand Down

0 comments on commit f9c9ac7

Please sign in to comment.