Skip to content

Commit b1d61ad

Browse files
findnatureavkr003
andauthored
refactor: use the built-in max/min to simplify the code (#1258)
Signed-off-by: findnature <cricis@aliyun.com> Co-authored-by: Abhinav Kumar <57705190+avkr003@users.noreply.github.com>
1 parent 4226567 commit b1d61ad

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

x/commitment/types/commitments.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ func (c Commitments) GetCreatorAccount() sdk.AccAddress {
137137
}
138138

139139
func (vesting *VestingTokens) VestedSoFar(ctx sdk.Context) math.Int {
140-
totalBlocks := ctx.BlockHeight() - vesting.StartBlock
141-
if totalBlocks > vesting.NumBlocks {
142-
totalBlocks = vesting.NumBlocks
143-
}
140+
totalBlocks := min(ctx.BlockHeight()-vesting.StartBlock, vesting.NumBlocks)
144141
return vesting.TotalAmount.Mul(math.NewInt(totalBlocks)).Quo(math.NewInt(vesting.NumBlocks))
145142
}
146143

0 commit comments

Comments
 (0)