Get proof type in NewWinningPoStProver constructor
This commit is contained in:
parent
bb3789b130
commit
5bf80a60f1
@ -426,11 +426,6 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
||||
return err
|
||||
}
|
||||
|
||||
winPt, err := spt.RegisteredWinningPoStProof()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mid, err := address.IDFromAddress(a)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting id address: %w", err)
|
||||
@ -447,7 +442,10 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
epp := storage.NewWinningPoStProver(smgr, dtypes.MinerID(mid), winPt)
|
||||
epp, err := storage.NewWinningPoStProver(api, smgr, dtypes.MinerID(mid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
beacon := beacon.NewMockBeacon(build.BlockDelay * time.Second)
|
||||
|
||||
|
@ -135,18 +135,11 @@ func StorageMiner(mctx helpers.MetricsCtx, lc fx.Lifecycle, api lapi.FullNode, h
|
||||
return nil, err
|
||||
}
|
||||
|
||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(sealer.SectorSize()) // TODO: this changes
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("bad sector size: %w", err)
|
||||
}
|
||||
|
||||
ppt, err := spt.RegisteredWindowPoStProof()
|
||||
fps, err := storage.NewWindowedPoStScheduler(api, sealer, maddr, worker)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fps := storage.NewWindowedPoStScheduler(api, sealer, maddr, worker, ppt)
|
||||
|
||||
sm, err := storage.NewMiner(api, maddr, worker, h, ds, sealer, sc, verif, tktFn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -133,8 +133,28 @@ type StorageWpp struct {
|
||||
winnRpt abi.RegisteredProof
|
||||
}
|
||||
|
||||
func NewWinningPoStProver(sb storage.Prover, miner dtypes.MinerID, winnRpt abi.RegisteredProof) *StorageWpp {
|
||||
return &StorageWpp{sb, abi.ActorID(miner), winnRpt}
|
||||
func NewWinningPoStProver(api api.FullNode, sb storage.Prover, miner dtypes.MinerID) (*StorageWpp, error) {
|
||||
ma, err := address.NewIDAddress(uint64(miner))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mss, err := api.StateMinerSectorSize(context.TODO(), ma, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting sector size: %w", err)
|
||||
}
|
||||
|
||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(mss)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wpt, err := spt.RegisteredWinningPoStProof()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &StorageWpp{sb, abi.ActorID(miner), wpt}, nil
|
||||
}
|
||||
|
||||
var _ gen.WinningPoStProver = (*StorageWpp)(nil)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
@ -36,8 +37,23 @@ type WindowPoStScheduler struct {
|
||||
//failLk sync.Mutex
|
||||
}
|
||||
|
||||
func NewWindowedPoStScheduler(api storageMinerApi, sb storage.Prover, actor address.Address, worker address.Address, rt abi.RegisteredProof) *WindowPoStScheduler {
|
||||
return &WindowPoStScheduler{api: api, prover: sb, actor: actor, worker: worker, proofType: rt}
|
||||
func NewWindowedPoStScheduler(api storageMinerApi, sb storage.Prover, actor address.Address, worker address.Address) (*WindowPoStScheduler, error) {
|
||||
mss, err := api.StateMinerSectorSize(context.TODO(), actor, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting sector size: %w", err)
|
||||
}
|
||||
|
||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(mss)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rt, err := spt.RegisteredWindowPoStProof()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &WindowPoStScheduler{api: api, prover: sb, actor: actor, worker: worker, proofType: rt}, nil
|
||||
}
|
||||
|
||||
const ProvingDeadlineEpochs = (30 * 60) / build.BlockDelay
|
||||
|
Loading…
Reference in New Issue
Block a user