p2p: using math.MaxInt32 in go std lib

This commit is contained in:
cuiweixie 2025-08-06 19:17:51 +08:00
parent 792de5d2e3
commit 888d4b7be6

View file

@ -171,8 +171,7 @@ func (t *Tracker) Capacity(kind uint64, targetRTT time.Duration) int {
// roundCapacity gives the integer value of a capacity.
// The result fits int32, and is guaranteed to be positive.
func roundCapacity(cap float64) int {
const maxInt32 = float64(1<<31 - 1)
return int(math.Min(maxInt32, math.Max(1, math.Ceil(cap))))
return int(math.Min(math.MaxInt32, math.Max(1, math.Ceil(cap))))
}
// Update modifies the peer's capacity values for a specific data type with a new