make storage miner acccept an interface to the sectorbuilder

This commit is contained in:
whyrusleeping 2020-01-08 17:10:17 -08:00
parent b7e35ae3ed
commit d08898ef37
3 changed files with 16 additions and 5 deletions

View File

@ -238,7 +238,7 @@ func Online() Option {
// Storage miner
ApplyIf(func(s *Settings) bool { return s.nodeType == repo.StorageMiner },
Override(new(*sectorbuilder.SectorBuilder), modules.SectorBuilder),
Override(new(storage.SectorBuilder), modules.SectorBuilder),
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
Override(new(storage.TicketFn), modules.SealTicketGen),
Override(new(*storage.Miner), modules.StorageMiner),

View File

@ -4,7 +4,6 @@ import (
"context"
"sync"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
@ -20,7 +19,7 @@ const StartConfidence = 4 // TODO: config
type fpostScheduler struct {
api storageMinerApi
sb *sectorbuilder.SectorBuilder
sb SectorBuilder
actor address.Address
worker address.Address

View File

@ -3,6 +3,7 @@ package storage
import (
"context"
"errors"
"io"
"time"
"github.com/ipfs/go-cid"
@ -36,7 +37,7 @@ type Miner struct {
worker address.Address
// Sealing
sb *sectorbuilder.SectorBuilder
sb SectorBuilder
sectors *statestore.StateStore
tktFn TicketFn
@ -71,7 +72,18 @@ type storageMinerApi interface {
WalletHas(context.Context, address.Address) (bool, error)
}
func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datastore.Batching, sb *sectorbuilder.SectorBuilder, tktFn TicketFn) (*Miner, error) {
type SectorBuilder interface {
RateLimit() func()
AddPiece(uint64, uint64, io.Reader, []uint64) (sectorbuilder.PublicPieceInfo, error)
SectorSize() uint64
AcquireSectorId() (uint64, error)
Scrub(sectorbuilder.SortedPublicSectorInfo) []*sectorbuilder.Fault
GenerateFallbackPoSt(sectorbuilder.SortedPublicSectorInfo, [sectorbuilder.CommLen]byte, []uint64) ([]sectorbuilder.EPostCandidate, []byte, error)
SealPreCommit(uint64, sectorbuilder.SealTicket, []sectorbuilder.PublicPieceInfo) (sectorbuilder.RawSealPreCommitOutput, error)
SealCommit(uint64, sectorbuilder.SealTicket, sectorbuilder.SealSeed, []sectorbuilder.PublicPieceInfo, sectorbuilder.RawSealPreCommitOutput) ([]byte, error)
}
func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datastore.Batching, sb SectorBuilder, tktFn TicketFn) (*Miner, error) {
return &Miner{
api: api,