panic on unknown pathType

This commit is contained in:
Anton Evangelatov 2021-05-11 18:14:01 +02:00
parent e07438417c
commit eb13c74dce

View File

@ -3,7 +3,7 @@ package stores
import ( import (
"context" "context"
"errors" "errors"
"math" "fmt"
"net/url" "net/url"
gopath "path" gopath "path"
"sort" "sort"
@ -385,12 +385,14 @@ func (i *Index) StorageBestAlloc(ctx context.Context, allocate storiface.SectorF
var candidates []storageEntry var candidates []storageEntry
var err error var err error
spaceReq := uint64(math.MaxUint64) var spaceReq uint64
switch pathType { switch pathType {
case storiface.PathSealing: case storiface.PathSealing:
spaceReq, err = allocate.SealSpaceUse(ssize) spaceReq, err = allocate.SealSpaceUse(ssize)
case storiface.PathStorage: case storiface.PathStorage:
spaceReq, err = allocate.StoreSpaceUse(ssize) spaceReq, err = allocate.StoreSpaceUse(ssize)
default:
panic(fmt.Sprintf("unexpected pathType: %s", pathType))
} }
if err != nil { if err != nil {
return nil, xerrors.Errorf("estimating required space: %w", err) return nil, xerrors.Errorf("estimating required space: %w", err)