Commit d70115a5 by 1808837298@qq.com

fix: remove useless code

parent 5d2c125d
...@@ -291,19 +291,19 @@ func CacheGetRandomSatisfiedChannel(group string, model string) (*Channel, error ...@@ -291,19 +291,19 @@ func CacheGetRandomSatisfiedChannel(group string, model string) (*Channel, error
} }
} }
} }
// 平滑系数 // 平滑系数
smoothingFactor := 10 smoothingFactor := 10
// Calculate the total weight of all channels up to endIdx // Calculate the total weight of all channels up to endIdx
totalWeight := 0 totalWeight := 0
for _, channel := range channels[:endIdx] { for _, channel := range channels[:endIdx] {
totalWeight += channel.GetWeight() + smoothingFactor totalWeight += channel.GetWeight() + smoothingFactor
} }
if totalWeight == 0 { //if totalWeight == 0 {
// If all weights are 0, select a channel randomly // // If all weights are 0, select a channel randomly
return channels[rand.Intn(endIdx)], nil // return channels[rand.Intn(endIdx)], nil
} //}
// Generate a random value in the range [0, totalWeight) // Generate a random value in the range [0, totalWeight)
randomWeight := rand.Intn(totalWeight) randomWeight := rand.Intn(totalWeight)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment