Drop SectorSizeForRegisteredProof
This commit is contained in:
parent
65efbfce12
commit
cd464ef916
@ -1,7 +1,6 @@
|
|||||||
package ffiwrapper
|
package ffiwrapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@ -19,36 +18,20 @@ func sizeFromConfig(cfg Config) (abi.SectorSize, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return SectorSizeForRegisteredProof(cfg.SealProofType)
|
return cfg.SealProofType.SectorSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this method after implementing it along side the registered proofs and importing it from there.
|
func SealProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, error) {
|
||||||
func SectorSizeForRegisteredProof(p abi.RegisteredProof) (abi.SectorSize, error) {
|
|
||||||
switch p {
|
|
||||||
case abi.RegisteredProof_StackedDRG32GiBSeal, abi.RegisteredProof_StackedDRG32GiBPoSt:
|
|
||||||
return 32 << 30, nil
|
|
||||||
case abi.RegisteredProof_StackedDRG2KiBSeal, abi.RegisteredProof_StackedDRG2KiBPoSt:
|
|
||||||
return 2 << 10, nil
|
|
||||||
case abi.RegisteredProof_StackedDRG8MiBSeal, abi.RegisteredProof_StackedDRG8MiBPoSt:
|
|
||||||
return 8 << 20, nil
|
|
||||||
case abi.RegisteredProof_StackedDRG512MiBSeal, abi.RegisteredProof_StackedDRG512MiBPoSt:
|
|
||||||
return 512 << 20, nil
|
|
||||||
default:
|
|
||||||
return 0, fmt.Errorf("unsupported registered proof %d", p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, abi.RegisteredProof, error) {
|
|
||||||
switch ssize {
|
switch ssize {
|
||||||
case 2 << 10:
|
case 2 << 10:
|
||||||
return abi.RegisteredProof_StackedDRG2KiBPoSt, abi.RegisteredProof_StackedDRG2KiBSeal, nil
|
return abi.RegisteredProof_StackedDRG2KiBSeal, nil
|
||||||
case 8 << 20:
|
case 8 << 20:
|
||||||
return abi.RegisteredProof_StackedDRG8MiBPoSt, abi.RegisteredProof_StackedDRG8MiBSeal, nil
|
return abi.RegisteredProof_StackedDRG8MiBSeal, nil
|
||||||
case 512 << 20:
|
case 512 << 20:
|
||||||
return abi.RegisteredProof_StackedDRG512MiBPoSt, abi.RegisteredProof_StackedDRG512MiBSeal, nil
|
return abi.RegisteredProof_StackedDRG512MiBSeal, nil
|
||||||
case 32 << 30:
|
case 32 << 30:
|
||||||
return abi.RegisteredProof_StackedDRG32GiBPoSt, abi.RegisteredProof_StackedDRG32GiBSeal, nil
|
return abi.RegisteredProof_StackedDRG32GiBSeal, nil
|
||||||
default:
|
default:
|
||||||
return 0, 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
|
return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ func GenerateUnsealedCID(proofType abi.RegisteredProof, pieces []abi.PieceInfo)
|
|||||||
sum += p.Size
|
sum += p.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize, err := SectorSizeForRegisteredProof(proofType)
|
ssize, err := proofType.SectorSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ type SectorMgr struct {
|
|||||||
type mockVerif struct{}
|
type mockVerif struct{}
|
||||||
|
|
||||||
func NewMockSectorMgr(threads int, ssize abi.SectorSize) *SectorMgr {
|
func NewMockSectorMgr(threads int, ssize abi.SectorSize) *SectorMgr {
|
||||||
rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize)
|
rt, err := ffiwrapper.SealProofTypeFromSectorSize(ssize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user