workers: Call find* on remote

This commit is contained in:
Łukasz Magiera 2020-03-19 03:23:21 +01:00
parent 94ebbd9d90
commit 2d1e30ae3b
3 changed files with 33 additions and 15 deletions

View File

@ -400,7 +400,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
smgr, err := advmgr.New(lr, stores.NewIndex(), &sectorbuilder.Config{
SealProofType: spt,
PoStProofType: ppt,
}, nil, stores.NewIndex())
}, nil)
if err != nil {
return err
}

View File

@ -12,13 +12,14 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/lotus/storage/sealmgr/stores"
"github.com/filecoin-project/specs-actors/actors/abi"
storage2 "github.com/filecoin-project/specs-storage/storage"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/impl"
"github.com/filecoin-project/lotus/storage/sealmgr"
"github.com/filecoin-project/lotus/storage/sealmgr/stores"
)
var log = logging.Logger("advmgr")
@ -29,6 +30,8 @@ type Worker interface {
sectorbuilder.Sealer
TaskTypes(context.Context) (map[sealmgr.TaskType]struct{}, error)
// Returns paths accessible to the worker
Paths(context.Context) ([]stores.StoragePath, error)
}
@ -36,39 +39,46 @@ type Manager struct {
workers []Worker
scfg *sectorbuilder.Config
ls stores.LocalStorage
storage *stores.Local
remoteHnd *stores.FetchHandler
ls stores.LocalStorage
storage *stores.Remote
localStore *stores.Local
remoteHnd *stores.FetchHandler
storage2.Prover
lk sync.Mutex
}
func New(ls stores.LocalStorage, si *stores.Index, cfg *sectorbuilder.Config, urls URLs, sindex stores.SectorIndex) (*Manager, error) {
stor, err := stores.NewLocal(ls)
func New(ls stores.LocalStorage, si stores.SectorIndex, cfg *sectorbuilder.Config, urls URLs, ca impl.CommonAPI) (*Manager, error) {
lstor, err := stores.NewLocal(ls)
if err != nil {
return nil, err
}
if err := stores.DeclareLocalStorage(context.TODO(), si, stor, urls, 10); err != nil {
if err := stores.DeclareLocalStorage(context.TODO(), si, lstor, urls, 10); err != nil {
log.Errorf("Declaring local storage failed: %+v")
}
prover, err := sectorbuilder.New(&readonlyProvider{stor: stor}, cfg)
prover, err := sectorbuilder.New(&readonlyProvider{stor: lstor}, cfg)
if err != nil {
return nil, xerrors.Errorf("creating prover instance: %w", err)
}
token, err := ca.AuthNew(context.TODO(), []api.Permission{"admin"})
headers := http.Header{}
headers.Add("Authorization", "Bearer "+string(token))
stor := stores.NewRemote(lstor, si, headers)
m := &Manager{
workers: []Worker{
//&LocalWorker{scfg: cfg, localStore: stor, storage: stor, sindex: sindex},
//&LocalWorker{scfg: cfg, localStore: lstor, storage: lstor, sindex: sindex},
},
scfg: cfg,
ls: ls,
storage: stor,
remoteHnd: &stores.FetchHandler{Store: stor},
ls: ls,
storage: stor,
localStore: lstor,
remoteHnd: &stores.FetchHandler{Store: lstor},
Prover: prover,
}
@ -82,7 +92,7 @@ func (m *Manager) AddLocalStorage(path string) error {
return xerrors.Errorf("expanding local path: %w", err)
}
if err := m.storage.OpenPath(path); err != nil {
if err := m.localStore.OpenPath(path); err != nil {
return xerrors.Errorf("opening local path: %w", err)
}

View File

@ -163,6 +163,14 @@ func (r *Remote) fetch(url, outname string) error {
}
func (r *Remote) FindBestAllocStorage(allocate sectorbuilder.SectorFileType, sealing bool) ([]StorageMeta, error) {
panic("todo")
}
func (r *Remote) FindSector(id abi.SectorID, typ sectorbuilder.SectorFileType) ([]StorageMeta, error) {
panic("todo")
}
func mergeDone(a func(), b func()) func() {
return func() {
a()