lotus/ffiwrapper/config.go

35 lines
873 B
Go
Raw Normal View History

2020-03-26 02:50:56 +00:00
package ffiwrapper
import (
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/abi"
)
type Config struct {
2020-06-15 12:32:17 +00:00
SealProofType abi.RegisteredSealProof
2020-03-26 02:50:56 +00:00
_ struct{} // guard against nameless init
}
func sizeFromConfig(cfg Config) (abi.SectorSize, error) {
2020-04-10 21:01:35 +00:00
return cfg.SealProofType.SectorSize()
2020-03-26 02:50:56 +00:00
}
2020-06-15 12:32:17 +00:00
func SealProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredSealProof, error) {
switch ssize {
case 2 << 10:
2020-06-15 12:32:17 +00:00
return abi.RegisteredSealProof_StackedDrg2KiBV1, nil
case 8 << 20:
2020-06-15 12:32:17 +00:00
return abi.RegisteredSealProof_StackedDrg8MiBV1, nil
case 512 << 20:
2020-06-15 12:32:17 +00:00
return abi.RegisteredSealProof_StackedDrg512MiBV1, nil
case 32 << 30:
2020-06-15 12:32:17 +00:00
return abi.RegisteredSealProof_StackedDrg32GiBV1, nil
2020-05-08 20:32:34 +00:00
case 64 << 30:
2020-06-15 12:32:17 +00:00
return abi.RegisteredSealProof_StackedDrg64GiBV1, nil
default:
2020-04-10 21:01:35 +00:00
return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
}
}