Optimizer: fix panic in prorate
This commit is contained in:
parent
90fdd8ee6b
commit
bd9f690107
1 changed files with 5 additions and 0 deletions
|
|
@ -559,6 +559,11 @@ func profileSlotsFromNow(profile []float64) []float64 {
|
|||
|
||||
// prorate adjusts the first slot's energy amount according to remaining duration
|
||||
func prorate[T constraints.Float](slots []T, firstSlotDuration time.Duration) []float32 {
|
||||
// return empty slice instead of nil to make api happy
|
||||
if len(slots) == 0 {
|
||||
return []float32{}
|
||||
}
|
||||
|
||||
res := slices.Clone(slots)
|
||||
res[0] = res[0] * T(firstSlotDuration) / T(tariff.SlotDuration)
|
||||
return lo.Map(res, func(f T, _ int) float32 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue