lotus/storage/sealer/proofpaths/cachefiles.go

56 lines
1.9 KiB
Go
Raw Normal View History

2023-06-28 11:56:00 +00:00
package proofpaths
import (
"fmt"
"regexp"
2023-06-28 11:56:00 +00:00
"github.com/filecoin-project/go-state-types/abi"
)
2023-12-23 17:49:11 +00:00
const dataFilePrefix = "sc-02-data-"
const TreeDName = dataFilePrefix + "tree-d.dat"
2023-06-28 11:56:00 +00:00
const TreeRLastPrefix = dataFilePrefix + "tree-r-last-"
const TreeCPrefix = dataFilePrefix + "tree-c-"
func IsFileTreeD(baseName string) bool {
return baseName == TreeDName
}
func IsFileTreeRLast(baseName string) bool {
// TreeRLastPrefix<int>.dat
reg := fmt.Sprintf(`^%s\d+\.dat$`, TreeRLastPrefix)
return regexp.MustCompile(reg).MatchString(baseName)
}
func IsFileTreeC(baseName string) bool {
// TreeCPrefix<int>.dat
reg := fmt.Sprintf(`^%s\d+\.dat$`, TreeCPrefix)
return regexp.MustCompile(reg).MatchString(baseName)
}
func IsTreeFile(baseName string) bool {
return IsFileTreeD(baseName) || IsFileTreeRLast(baseName) || IsFileTreeC(baseName)
}
2023-06-28 11:56:00 +00:00
func LayerFileName(layer int) string {
return fmt.Sprintf("%slayer-%d.dat", dataFilePrefix, layer)
}
func SDRLayers(spt abi.RegisteredSealProof) (int, error) {
switch spt {
2023-10-17 13:19:46 +00:00
case abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg2KiBV1_1, abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep:
2023-06-28 11:56:00 +00:00
return 2, nil
2023-10-17 13:19:46 +00:00
case abi.RegisteredSealProof_StackedDrg8MiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1_1, abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep:
2023-06-28 11:56:00 +00:00
return 2, nil
2023-10-17 13:19:46 +00:00
case abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg512MiBV1_1, abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep:
2023-06-28 11:56:00 +00:00
return 2, nil
2023-10-17 13:19:46 +00:00
case abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1_1, abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep:
2023-06-28 11:56:00 +00:00
return 11, nil
2023-10-17 13:19:46 +00:00
case abi.RegisteredSealProof_StackedDrg64GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1_1, abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep:
2023-06-28 11:56:00 +00:00
return 11, nil
default:
return 0, fmt.Errorf("unsupported proof type: %v", spt)
}
}