Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mak Muftic committed Nov 11, 2020
1 parent 8f81a3a commit 16ad486
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions internal/payout/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const (
func CalculatePayoutDistributionByNode(
payoutDetails map[string]models.NodeStatsDetails,
totalReward float64,
loadBalancerFee float64,
loadBalancerFeePercentage float64,
) map[string]big.Int {
var rewardPool = totalReward

loadbalancerFixFee := rewardPool * loadBalancerFee
rewardPool -= loadbalancerFixFee
loadbalancerReward := rewardPool * loadBalancerFeePercentage
rewardPool -= loadbalancerReward

livelinessRewardPool := rewardPool * livelinessRewardPercentage
requestsRewardPool := rewardPool * requestsRewardPercentage
Expand All @@ -37,11 +37,13 @@ func CalculatePayoutDistributionByNode(

for nodeId, nodeStatsDetails := range payoutDetails {
// liveliness rewards
nodeLivelinessRewardPercentage := nodeStatsDetails.TotalPings / totalNumberOfPings
livelinessReward := livelinessRewardPool * nodeLivelinessRewardPercentage
livelinessReward = math.Floor(livelinessReward)
totalDistributedLivelinessRewards += livelinessReward

livelinessReward := float64(0)
if totalNumberOfPings != 0 && nodeStatsDetails.TotalPings != 0 {
nodeLivelinessRewardPercentage := nodeStatsDetails.TotalPings / totalNumberOfPings
livelinessReward = livelinessRewardPool * nodeLivelinessRewardPercentage
livelinessReward = math.Floor(livelinessReward)
totalDistributedLivelinessRewards += livelinessReward
}
// requests rewards
requestsReward := float64(0)
if totalNumberOfRequests != 0 && nodeStatsDetails.TotalRequests != 0 {
Expand Down

0 comments on commit 16ad486

Please sign in to comment.