lotus/ffiwrapper/config.go

39 lines
1008 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 {
SealProofType abi.RegisteredProof
_ struct{} // guard against nameless init
}
func sizeFromConfig(cfg Config) (abi.SectorSize, error) {
if cfg.SealProofType == abi.RegisteredProof(0) {
return abi.SectorSize(0), xerrors.New("must specify a seal proof type from abi.RegisteredProof")
}
2020-04-10 21:01:35 +00:00
return cfg.SealProofType.SectorSize()
2020-03-26 02:50:56 +00:00
}
2020-04-10 21:01:35 +00:00
func SealProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, error) {
switch ssize {
case 2 << 10:
2020-04-10 21:01:35 +00:00
return abi.RegisteredProof_StackedDRG2KiBSeal, nil
case 8 << 20:
2020-04-10 21:01:35 +00:00
return abi.RegisteredProof_StackedDRG8MiBSeal, nil
case 512 << 20:
2020-04-10 21:01:35 +00:00
return abi.RegisteredProof_StackedDRG512MiBSeal, nil
case 32 << 30:
2020-04-10 21:01:35 +00:00
return abi.RegisteredProof_StackedDRG32GiBSeal, nil
2020-05-08 20:32:34 +00:00
case 64 << 30:
return abi.RegisteredProof_StackedDRG64GiBSeal, nil
default:
2020-04-10 21:01:35 +00:00
return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
}
}