in store/slot.go [106:146]
func ParseSlotRange(s string) (*SlotRange, error) {
numberOfRanges := strings.Count(s, "-")
if numberOfRanges > 1 {
return nil, fmt.Errorf("%w, cannot have more than one range", consts.ErrInvalidArgument)
}
index := strings.IndexByte(s, '-')
if index == -1 {
start, err := strconv.Atoi(s)
if err != nil {
return nil, err
}
if start < MinSlotID || start > MaxSlotID {
return nil, ErrSlotOutOfRange
}
return &SlotRange{
Start: start,
Stop: start,
}, nil
}
start, err := strconv.Atoi(s[0:index])
if err != nil {
return nil, err
}
stop, err := strconv.Atoi(s[index+1:])
if err != nil {
return nil, err
}
if start > stop {
return nil, errors.New("start slot id greater than stop slot id")
}
if (start < MinSlotID || start > MaxSlotID) ||
(stop < MinSlotID || stop > MaxSlotID) {
return nil, ErrSlotOutOfRange
}
return &SlotRange{
Start: start,
Stop: stop,
}, nil
}