Skip to content

Commit

Permalink
Check if the coin is zero, not positive
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Aug 8, 2023
1 parent be2c8ef commit d733409
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x/node/keeper/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func (k *Keeper) FundCommunityPool(ctx sdk.Context, fromAddr sdk.AccAddress, coin sdk.Coin) error {
if !coin.IsPositive() {
if coin.IsZero() {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion x/provider/keeper/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func (k *Keeper) FundCommunityPool(ctx sdk.Context, fromAddr sdk.AccAddress, coin sdk.Coin) error {
if !coin.IsPositive() {
if coin.IsZero() {
return nil
}

Expand Down
4 changes: 1 addition & 3 deletions x/subscription/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc

var (
gigabytePrice sdk.Coin // Gigabyte price based on the deposit amount and gigabytes (for NodeSubscription).
currentAmount = sdk.ZeroInt() // Amount to be paid for the current utilization (for NodeSubscription).
previousAmount = sdk.ZeroInt() // Amount paid for previous utilization (for NodeSubscription).
)

Expand All @@ -57,10 +56,9 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc

// Based on the subscription type (NodeSubscription), calculate the current payment amount.
if s, ok := subscription.(*types.NodeSubscription); ok && s.Gigabytes != 0 {
currentAmount = hubutils.AmountForBytes(gigabytePrice.Amount, alloc.UtilisedBytes)

// Calculate the payment to be made for the current utilization.
var (
currentAmount = hubutils.AmountForBytes(gigabytePrice.Amount, alloc.UtilisedBytes)
payment = sdk.NewCoin(gigabytePrice.Denom, currentAmount.Sub(previousAmount))
stakingShare = k.node.StakingShare(ctx)
stakingReward = hubutils.GetProportionOfCoin(payment, stakingShare)
Expand Down

0 comments on commit d733409

Please sign in to comment.