refactor: replace math.Min and math.Max with built-in min/max

Reference: https://github.com/lightningnetwork/lnd/pull/9451#pullrequestreview-2580942691
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun committed 2025-02-06 09:46:40 +08:00
1 parent 0899cee987
commit e56a7945be
4 files changed
+6 -21

No files matched your search

+3 -11
View File
@@ -7,7 +7,6 @@ import (
"crypto/sha256"
"errors"
"fmt"
"math"
"slices"
"sync"
@@ -9512,7 +9511,7 @@ func (lc *LightningChannel) MaxFeeRate(
// rather than us decreasing in local balance. The max fee rate is
// always floored by the current fee rate of the channel.
idealMaxFee := float64(baseBalance) * maxAllocation
maxFee := math.Max(float64(currentFee), idealMaxFee)
maxFee := max(float64(currentFee), idealMaxFee)
maxFeeAllocation := maxFee / float64(baseBalance)
maxFeeRate := chainfee.SatPerKWeight(maxFee / (float64(weight) / 1000))
@@ -9538,17 +9537,10 @@ func (lc *LightningChannel) IdealCommitFeeRate(netFeeRate, minRelayFeeRate,
switch lc.channelState.ChanType.HasAnchors() &&
maxFeeRate > maxAnchorCommitFeeRate {
case true:
commitFeeRate = chainfee.SatPerKWeight(
math.Min(
float64(netFeeRate),
float64(maxAnchorCommitFeeRate),
),
)
commitFeeRate = min(netFeeRate, maxAnchorCommitFeeRate)
case false:
commitFeeRate = chainfee.SatPerKWeight(
math.Min(float64(netFeeRate), float64(maxFeeRate)),
)
commitFeeRate = min(netFeeRate, maxFeeRate)
}
if commitFeeRate >= minRelayFeeRate {