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) {
|
2020-03-27 20:08:06 +00:00
|
|
|
switch ssize {
|
|
|
|
case 2 << 10:
|
2020-04-10 21:01:35 +00:00
|
|
|
return abi.RegisteredProof_StackedDRG2KiBSeal, nil
|
2020-03-27 20:08:06 +00:00
|
|
|
case 8 << 20:
|
2020-04-10 21:01:35 +00:00
|
|
|
return abi.RegisteredProof_StackedDRG8MiBSeal, nil
|
2020-03-27 20:08:06 +00:00
|
|
|
case 512 << 20:
|
2020-04-10 21:01:35 +00:00
|
|
|
return abi.RegisteredProof_StackedDRG512MiBSeal, nil
|
2020-03-27 20:08:06 +00:00
|
|
|
case 32 << 30:
|
2020-04-10 21:01:35 +00:00
|
|
|
return abi.RegisteredProof_StackedDRG32GiBSeal, nil
|
2020-03-27 20:08:06 +00:00
|
|
|
default:
|
2020-04-10 21:01:35 +00:00
|
|
|
return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
|
2020-03-27 20:08:06 +00:00
|
|
|
}
|
|
|
|
}
|