From 06b746a740563169d53dbf9e35b1497016aff48f Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Sat, 2 Mar 2024 23:02:49 +0800 Subject: [PATCH] fix: remove useless code --- model/cache.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/cache.go b/model/cache.go index dc856393..8294e731 100644 --- a/model/cache.go +++ b/model/cache.go @@ -291,19 +291,19 @@ func CacheGetRandomSatisfiedChannel(group string, model string) (*Channel, error } } } + // 平滑系数 smoothingFactor := 10 - // Calculate the total weight of all channels up to endIdx totalWeight := 0 for _, channel := range channels[:endIdx] { totalWeight += channel.GetWeight() + smoothingFactor } - if totalWeight == 0 { - // If all weights are 0, select a channel randomly - return channels[rand.Intn(endIdx)], nil - } + //if totalWeight == 0 { + // // If all weights are 0, select a channel randomly + // return channels[rand.Intn(endIdx)], nil + //} // Generate a random value in the range [0, totalWeight) randomWeight := rand.Intn(totalWeight)