v1.27.0-a #10
@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPathTypeFilters(t *testing.T) {
|
func TestPathTypeFilters(t *testing.T) {
|
||||||
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
runTest := func(t *testing.T, name string, asserts func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func())) {
|
runTest := func(t *testing.T, name string, asserts func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func())) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
|
@ -495,6 +495,22 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
|
|||||||
var out storiface.SectorPaths
|
var out storiface.SectorPaths
|
||||||
var storageIDs storiface.SectorPaths
|
var storageIDs storiface.SectorPaths
|
||||||
|
|
||||||
|
allocPathOk := func(canSeal, canStore bool, allowTypes, denyTypes []string, fileType storiface.SectorFileType) bool {
|
||||||
|
if (pathType == storiface.PathSealing) && !canSeal {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathType == storiface.PathStorage) && !canStore {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !fileType.Allowed(allowTypes, denyTypes) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// First find existing files
|
// First find existing files
|
||||||
for _, fileType := range storiface.PathTypes {
|
for _, fileType := range storiface.PathTypes {
|
||||||
// also try to find existing sectors if we're allocating
|
// also try to find existing sectors if we're allocating
|
||||||
@ -520,6 +536,10 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if allocate.Has(fileType) && !allocPathOk(info.CanSeal, info.CanStore, info.AllowTypes, info.DenyTypes, fileType) {
|
||||||
|
continue // allocate request for a path of different type
|
||||||
|
}
|
||||||
|
|
||||||
spath := p.sectorPath(sid.ID, fileType)
|
spath := p.sectorPath(sid.ID, fileType)
|
||||||
storiface.SetPathByType(&out, fileType, spath)
|
storiface.SetPathByType(&out, fileType, spath)
|
||||||
storiface.SetPathByType(&storageIDs, fileType, string(info.ID))
|
storiface.SetPathByType(&storageIDs, fileType, string(info.ID))
|
||||||
@ -554,15 +574,7 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pathType == storiface.PathSealing) && !si.CanSeal {
|
if !allocPathOk(si.CanSeal, si.CanStore, si.AllowTypes, si.DenyTypes, fileType) {
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathType == storiface.PathStorage) && !si.CanStore {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if !fileType.Allowed(si.AllowTypes, si.DenyTypes) {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user