Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve getToDistributedCoinsFromGauges #2014

Merged
merged 3 commits into from
Jul 11, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions x/incentives/keeper/distribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ func (k Keeper) getDistributedCoinsFromGauges(gauges []types.Gauge) sdk.Coins {
}

func (k Keeper) getToDistributeCoinsFromGauges(gauges []types.Gauge) sdk.Coins {
// TODO: Consider optimizing this in the future to only require one iteration over all gauges.
coins := k.getCoinsFromGauges(gauges)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (k Keeper) getCoinsFromGauges(gauges []types.Gauge) sdk.Coins {..} is unused now, maybe you can remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll remove it

distributed := k.getDistributedCoinsFromGauges(gauges)
coins := sdk.Coins{}
distributed := sdk.Coins{}

for _, gauge := range gauges {
coins = coins.Add(gauge.Coins...)
distributed = distributed.Add(gauge.DistributedCoins...)
}

return coins.Sub(distributed)
}

Expand Down