Merge PR #3522: get rid of double negatives: IsNotNegative -> IsAnyNegative

This commit is contained in:
Alessio Treglia
2019-02-06 14:45:15 -08:00
committed by Jack Zampolin
parent 17c84ab34a
commit b63b6254c8
9 changed files with 18 additions and 17 deletions
+9 -9
View File
@@ -262,7 +262,7 @@ func (coins Coins) Minus(coinsB Coins) Coins {
// negative coin amount was returned.
func (coins Coins) SafeMinus(coinsB Coins) (Coins, bool) {
diff := coins.safePlus(coinsB.negative())
return diff, !diff.IsNotNegative()
return diff, diff.IsAnyNegative()
}
// IsAllGT returns true if for every denom in coins, the denom is present at a
@@ -284,7 +284,7 @@ func (coins Coins) IsAllGTE(coinsB Coins) bool {
return true
}
return diff.IsNotNegative()
return !diff.IsAnyNegative()
}
// IsAllLT returns True iff for every denom in coins, the denom is present at
@@ -380,22 +380,22 @@ func (coins Coins) IsPositive() bool {
return true
}
// IsNotNegative returns true if there is no coin amount with a negative value
// (even no coins is true here).
//
// IsAnyNegative returns true if there is at least one coin whose amount
// is negative; returns false otherwise. It returns false if the coin set
// is empty too.
// TODO: Remove once unsigned integers are used.
func (coins Coins) IsNotNegative() bool {
func (coins Coins) IsAnyNegative() bool {
if len(coins) == 0 {
return true
return false
}
for _, coin := range coins {
if coin.IsNegative() {
return false
return true
}
}
return true
return false
}
// negative returns a set of coins with all amount negative.