Skip to content

Commit

Permalink
storage: Move storage/sealer/stores to storage/paths
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jun 14, 2022
1 parent 82857e6 commit 28099a3
Show file tree
Hide file tree
Showing 52 changed files with 305 additions and 305 deletions.
18 changes: 9 additions & 9 deletions cmd/lotus-miner/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/paths"
sealing2 "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
stores "github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -213,7 +213,7 @@ var initCmd = &cli.Command{
return err
}

var localPaths []stores.LocalPath
var localPaths []paths.LocalPath

if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 {
log.Infof("Setting up storage config with presealed sectors: %v", pssb)
Expand All @@ -223,14 +223,14 @@ var initCmd = &cli.Command{
if err != nil {
return err
}
localPaths = append(localPaths, stores.LocalPath{
localPaths = append(localPaths, paths.LocalPath{
Path: psp,
})
}
}

if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&stores.LocalStorageMeta{
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: true,
Expand All @@ -244,12 +244,12 @@ var initCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
}

localPaths = append(localPaths, stores.LocalPath{
localPaths = append(localPaths, paths.LocalPath{
Path: lr.Path(),
})
}

if err := lr.SetStorage(func(sc *stores.StorageConfig) {
if err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
Expand Down Expand Up @@ -458,13 +458,13 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api v1api.FullNode
wsts := statestore.New(namespace.Wrap(mds, modules.WorkerCallsPrefix))
smsts := statestore.New(namespace.Wrap(mds, modules.ManagerWorkPrefix))

si := stores.NewIndex()
si := paths.NewIndex()

lstor, err := stores.NewLocal(ctx, lr, si, nil)
lstor, err := paths.NewLocal(ctx, lr, si, nil)
if err != nil {
return err
}
stor := stores.NewRemote(lstor, si, http.Header(sa), 10, &stores.DefaultPartialFileHandler{})
stor := paths.NewRemote(lstor, si, http.Header(sa), 10, &paths.DefaultPartialFileHandler{})

smgr, err := sealer.New(ctx, lstor, stor, lr, si, sealer.Config{
ParallelFetchLimit: 10,
Expand Down
14 changes: 7 additions & 7 deletions cmd/lotus-miner/init_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/filecoin-project/lotus/lib/backupds"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/paths"
)

var restoreCmd = &cli.Command{
Expand All @@ -52,7 +52,7 @@ var restoreCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
log.Info("Initializing lotus miner using a backup")

var storageCfg *stores.StorageConfig
var storageCfg *paths.StorageConfig
if cctx.IsSet("storage-config") {
cf, err := homedir.Expand(cctx.String("storage-config"))
if err != nil {
Expand All @@ -64,7 +64,7 @@ var restoreCmd = &cli.Command{
return xerrors.Errorf("reading storage config: %w", err)
}

storageCfg = &stores.StorageConfig{}
storageCfg = &paths.StorageConfig{}
err = json.Unmarshal(cfb, storageCfg)
if err != nil {
return xerrors.Errorf("cannot unmarshal json for storage config: %w", err)
Expand Down Expand Up @@ -95,7 +95,7 @@ var restoreCmd = &cli.Command{
},
}

func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *paths.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
if cctx.Args().Len() != 1 {
return xerrors.Errorf("expected 1 argument")
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
if strConfig != nil {
log.Info("Restoring storage path config")

err = lr.SetStorage(func(scfg *stores.StorageConfig) {
err = lr.SetStorage(func(scfg *paths.StorageConfig) {
*scfg = *strConfig
})
if err != nil {
Expand All @@ -223,8 +223,8 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
} else {
log.Warn("--storage-config NOT SET. NO SECTOR PATHS WILL BE CONFIGURED")
// setting empty config to allow miner to be started
if err := lr.SetStorage(func(sc *stores.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, stores.LocalPath{})
if err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{})
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-miner/init_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/paths"
)

const (
Expand Down Expand Up @@ -78,7 +78,7 @@ var serviceCmd = &cli.Command{
return xerrors.Errorf("please provide Lotus markets repo path via flag %s", FlagMarketsRepo)
}

if err := restore(ctx, cctx, repoPath, &stores.StorageConfig{}, func(cfg *config.StorageMiner) error {
if err := restore(ctx, cctx, repoPath, &paths.StorageConfig{}, func(cfg *config.StorageMiner) error {
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
cfg.Subsystems.EnableMining = false
cfg.Subsystems.EnableSealing = false
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-miner/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/tablewriter"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/stores"
storiface "github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -145,7 +145,7 @@ over time
}
}

cfg := &stores.LocalStorageMeta{
cfg := &paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"),
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-seed/seed/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/storage/paths"
ffiwrapper "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/storage/sealer/stores"
storiface "github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -127,7 +127,7 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
}

{
b, err := json.MarshalIndent(&stores.LocalStorageMeta{
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 0, // read-only
CanSeal: false,
Expand Down
20 changes: 10 additions & 10 deletions cmd/lotus-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer"
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
stores "github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -384,10 +384,10 @@ var runCmd = &cli.Command{
return err
}

var localPaths []stores.LocalPath
var localPaths []paths.LocalPath

if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&stores.LocalStorageMeta{
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: true,
Expand All @@ -401,12 +401,12 @@ var runCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
}

localPaths = append(localPaths, stores.LocalPath{
localPaths = append(localPaths, paths.LocalPath{
Path: lr.Path(),
})
}

if err := lr.SetStorage(func(sc *stores.StorageConfig) {
if err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
Expand Down Expand Up @@ -456,7 +456,7 @@ var runCmd = &cli.Command{
}
}

localStore, err := stores.NewLocal(ctx, lr, nodeApi, []string{"http://" + address + "/remote"})
localStore, err := paths.NewLocal(ctx, lr, nodeApi, []string{"http://" + address + "/remote"})
if err != nil {
return err
}
Expand All @@ -467,10 +467,10 @@ var runCmd = &cli.Command{
return xerrors.Errorf("could not get api info: %w", err)
}

remote := stores.NewRemote(localStore, nodeApi, sminfo.AuthHeader(), cctx.Int("parallel-fetch-limit"),
&stores.DefaultPartialFileHandler{})
remote := paths.NewRemote(localStore, nodeApi, sminfo.AuthHeader(), cctx.Int("parallel-fetch-limit"),
&paths.DefaultPartialFileHandler{})

fh := &stores.FetchHandler{Local: localStore, PfHandler: &stores.DefaultPartialFileHandler{}}
fh := &paths.FetchHandler{Local: localStore, PfHandler: &paths.DefaultPartialFileHandler{}}
remoteHandler := func(w http.ResponseWriter, r *http.Request) {
if !auth.HasPerm(r.Context(), nil, api.PermAdmin) {
w.WriteHeader(401)
Expand Down Expand Up @@ -561,7 +561,7 @@ var runCmd = &cli.Command{
}

go func() {
heartbeats := time.NewTicker(stores.HeartbeatInterval)
heartbeats := time.NewTicker(paths.HeartbeatInterval)
defer heartbeats.Stop()

var redeclareStorage bool
Expand Down
10 changes: 5 additions & 5 deletions cmd/lotus-worker/sealworker/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/lib/rpcenc"
"github.com/filecoin-project/lotus/metrics/proxy"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer"
"github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -55,8 +55,8 @@ func WorkerHandler(authv func(ctx context.Context, token string) ([]auth.Permiss
type Worker struct {
*sealer.LocalWorker

LocalStore *stores.Local
Storage stores.LocalStorage
LocalStore *paths.Local
Storage paths.LocalStorage

disabled int64
}
Expand All @@ -75,8 +75,8 @@ func (w *Worker) StorageAddLocal(ctx context.Context, path string) error {
return xerrors.Errorf("opening local path: %w", err)
}

if err := w.Storage.SetStorage(func(sc *stores.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, stores.LocalPath{Path: path})
if err := w.Storage.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: path})
}); err != nil {
return xerrors.Errorf("get storage config: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-worker/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/xerrors"

lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -101,7 +101,7 @@ var storageAttachCmd = &cli.Command{
}
}

cfg := &stores.LocalStorageMeta{
cfg := &paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"),
Expand Down
12 changes: 6 additions & 6 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes"
testing2 "github.com/filecoin-project/lotus/node/modules/testing"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/paths"
sectorstorage "github.com/filecoin-project/lotus/storage/sealer"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
mock2 "github.com/filecoin-project/lotus/storage/sealer/mock"
stores "github.com/filecoin-project/lotus/storage/sealer/stores"
)

func init() {
Expand Down Expand Up @@ -546,8 +546,8 @@ func (n *Ensemble) Start() *Ensemble {
// using real proofs, therefore need real sectors.
if !n.bootstrapped && !n.options.mockProofs {
psd := m.PresealDir
err := lr.SetStorage(func(sc *stores.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, stores.LocalPath{Path: psd})
err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: psd})
})

require.NoError(n.t, err)
Expand Down Expand Up @@ -698,15 +698,15 @@ func (n *Ensemble) Start() *Ensemble {

addr := m.RemoteListener.Addr().String()

localStore, err := stores.NewLocal(ctx, lr, m.MinerNode, []string{"http://" + addr + "/remote"})
localStore, err := paths.NewLocal(ctx, lr, m.MinerNode, []string{"http://" + addr + "/remote"})
require.NoError(n.t, err)

auth := http.Header(nil)

remote := stores.NewRemote(localStore, m.MinerNode, auth, 20, &stores.DefaultPartialFileHandler{})
remote := paths.NewRemote(localStore, m.MinerNode, auth, 20, &paths.DefaultPartialFileHandler{})
store := m.options.workerStorageOpt(remote)

fh := &stores.FetchHandler{Local: localStore, PfHandler: &stores.DefaultPartialFileHandler{}}
fh := &paths.FetchHandler{Local: localStore, PfHandler: &paths.DefaultPartialFileHandler{}}
m.FetchHandler = fh.ServeHTTP

wsts := statestore.New(namespace.Wrap(ds, modules.WorkerCallsPrefix))
Expand Down
4 changes: 2 additions & 2 deletions itests/kit/node_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/stores"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -182,7 +182,7 @@ func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, weight uint64
require.NoError(t, err)
}

cfg := &stores.LocalStorageMeta{
cfg := &paths.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: weight,
CanSeal: seal,
Expand Down
Loading

0 comments on commit 28099a3

Please sign in to comment.