make repo not depend on ffi

This commit is contained in:
Łukasz Magiera 2022-11-01 11:01:31 +00:00
parent 5f5cc794f0
commit ec89424c42
27 changed files with 166 additions and 173 deletions

View File

@ -49,6 +49,7 @@ import (
"github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/journal/fsjournal" "github.com/filecoin-project/lotus/journal/fsjournal"
storageminer "github.com/filecoin-project/lotus/miner" storageminer "github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
@ -218,7 +219,7 @@ var initCmd = &cli.Command{
return err return err
} }
var localPaths []paths.LocalPath var localPaths []storiface.LocalPath
if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 { if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 {
log.Infof("Setting up storage config with presealed sectors: %v", pssb) log.Infof("Setting up storage config with presealed sectors: %v", pssb)
@ -228,14 +229,14 @@ var initCmd = &cli.Command{
if err != nil { if err != nil {
return err return err
} }
localPaths = append(localPaths, paths.LocalPath{ localPaths = append(localPaths, storiface.LocalPath{
Path: psp, Path: psp,
}) })
} }
} }
if !cctx.Bool("no-local-storage") { if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: true, CanSeal: true,
@ -249,12 +250,12 @@ var initCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
} }
localPaths = append(localPaths, paths.LocalPath{ localPaths = append(localPaths, storiface.LocalPath{
Path: lr.Path(), Path: lr.Path(),
}) })
} }
if err := lr.SetStorage(func(sc *paths.StorageConfig) { if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...) sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil { }); err != nil {
return xerrors.Errorf("set storage config: %w", err) return xerrors.Errorf("set storage config: %w", err)
@ -471,7 +472,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api v1api.FullNode
} }
stor := paths.NewRemote(lstor, si, http.Header(sa), 10, &paths.DefaultPartialFileHandler{}) stor := paths.NewRemote(lstor, si, http.Header(sa), 10, &paths.DefaultPartialFileHandler{})
smgr, err := sealer.New(ctx, lstor, stor, lr, si, sealer.Config{ smgr, err := sealer.New(ctx, lstor, stor, lr, si, config.SealerConfig{
ParallelFetchLimit: 10, ParallelFetchLimit: 10,
AllowAddPiece: true, AllowAddPiece: true,
AllowPreCommit1: true, AllowPreCommit1: true,
@ -481,7 +482,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api v1api.FullNode
AllowReplicaUpdate: true, AllowReplicaUpdate: true,
AllowProveReplicaUpdate2: true, AllowProveReplicaUpdate2: true,
AllowRegenSectorKey: true, AllowRegenSectorKey: true,
}, wsts, smsts) }, config.ProvingConfig{}, wsts, smsts)
if err != nil { if err != nil {
return err return err
} }

View File

@ -27,7 +27,7 @@ import (
"github.com/filecoin-project/lotus/lib/backupds" "github.com/filecoin-project/lotus/lib/backupds"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
var restoreCmd = &cli.Command{ var restoreCmd = &cli.Command{
@ -52,7 +52,7 @@ var restoreCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
log.Info("Initializing lotus miner using a backup") log.Info("Initializing lotus miner using a backup")
var storageCfg *paths.StorageConfig var storageCfg *storiface.StorageConfig
if cctx.IsSet("storage-config") { if cctx.IsSet("storage-config") {
cf, err := homedir.Expand(cctx.String("storage-config")) cf, err := homedir.Expand(cctx.String("storage-config"))
if err != nil { if err != nil {
@ -64,7 +64,7 @@ var restoreCmd = &cli.Command{
return xerrors.Errorf("reading storage config: %w", err) return xerrors.Errorf("reading storage config: %w", err)
} }
storageCfg = &paths.StorageConfig{} storageCfg = &storiface.StorageConfig{}
err = json.Unmarshal(cfb, storageCfg) err = json.Unmarshal(cfb, storageCfg)
if err != nil { if err != nil {
return xerrors.Errorf("cannot unmarshal json for storage config: %w", err) return xerrors.Errorf("cannot unmarshal json for storage config: %w", err)
@ -95,7 +95,7 @@ var restoreCmd = &cli.Command{
}, },
} }
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 { func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *storiface.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx) return lcli.IncorrectNumArgs(cctx)
} }
@ -214,7 +214,7 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
if strConfig != nil { if strConfig != nil {
log.Info("Restoring storage path config") log.Info("Restoring storage path config")
err = lr.SetStorage(func(scfg *paths.StorageConfig) { err = lr.SetStorage(func(scfg *storiface.StorageConfig) {
*scfg = *strConfig *scfg = *strConfig
}) })
if err != nil { if err != nil {
@ -223,8 +223,8 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
} else { } else {
log.Warn("--storage-config NOT SET. NO SECTOR PATHS WILL BE CONFIGURED") log.Warn("--storage-config NOT SET. NO SECTOR PATHS WILL BE CONFIGURED")
// setting empty config to allow miner to be started // setting empty config to allow miner to be started
if err := lr.SetStorage(func(sc *paths.StorageConfig) { if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{}) sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{})
}); err != nil { }); err != nil {
return xerrors.Errorf("set storage config: %w", err) return xerrors.Errorf("set storage config: %w", err)
} }

View File

@ -17,7 +17,7 @@ import (
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util" cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
const ( const (
@ -78,7 +78,7 @@ var serviceCmd = &cli.Command{
return xerrors.Errorf("please provide Lotus markets repo path via flag %s", FlagMarketsRepo) return xerrors.Errorf("please provide Lotus markets repo path via flag %s", FlagMarketsRepo)
} }
if err := restore(ctx, cctx, repoPath, &paths.StorageConfig{}, func(cfg *config.StorageMiner) error { if err := restore(ctx, cctx, repoPath, &storiface.StorageConfig{}, func(cfg *config.StorageMiner) error {
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService) cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
cfg.Subsystems.EnableMining = false cfg.Subsystems.EnableMining = false
cfg.Subsystems.EnableSealing = false cfg.Subsystems.EnableSealing = false

View File

@ -29,7 +29,6 @@ import (
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/tablewriter" "github.com/filecoin-project/lotus/lib/tablewriter"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline" sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
@ -148,7 +147,7 @@ over time
} }
} }
cfg := &paths.LocalStorageMeta{ cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"), Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"), CanSeal: cctx.Bool("seal"),

View File

@ -27,7 +27,6 @@ import (
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key" "github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/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/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
@ -126,7 +125,7 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
} }
{ {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 0, // read-only Weight: 0, // read-only
CanSeal: false, CanSeal: false,

View File

@ -447,10 +447,10 @@ var runCmd = &cli.Command{
return err return err
} }
var localPaths []paths.LocalPath var localPaths []storiface.LocalPath
if !cctx.Bool("no-local-storage") { if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: true, CanSeal: true,
@ -464,12 +464,12 @@ var runCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
} }
localPaths = append(localPaths, paths.LocalPath{ localPaths = append(localPaths, storiface.LocalPath{
Path: lr.Path(), Path: lr.Path(),
}) })
} }
if err := lr.SetStorage(func(sc *paths.StorageConfig) { if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...) sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil { }); err != nil {
return xerrors.Errorf("set storage config: %w", err) return xerrors.Errorf("set storage config: %w", err)

View File

@ -92,8 +92,8 @@ func (w *Worker) StorageAddLocal(ctx context.Context, path string) error {
return xerrors.Errorf("opening local path: %w", err) return xerrors.Errorf("opening local path: %w", err)
} }
if err := w.Storage.SetStorage(func(sc *paths.StorageConfig) { if err := w.Storage.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: path}) sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{Path: path})
}); err != nil { }); err != nil {
return xerrors.Errorf("get storage config: %w", err) return xerrors.Errorf("get storage config: %w", err)
} }
@ -127,8 +127,8 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {
// drop from the persisted storage.json // drop from the persisted storage.json
var found bool var found bool
if err := w.Storage.SetStorage(func(sc *paths.StorageConfig) { if err := w.Storage.SetStorage(func(sc *storiface.StorageConfig) {
out := make([]paths.LocalPath, 0, len(sc.StoragePaths)) out := make([]storiface.LocalPath, 0, len(sc.StoragePaths))
for _, storagePath := range sc.StoragePaths { for _, storagePath := range sc.StoragePaths {
if storagePath.Path != path { if storagePath.Path != path {
out = append(out, storagePath) out = append(out, storagePath)

View File

@ -13,7 +13,6 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -103,7 +102,7 @@ var storageAttachCmd = &cli.Command{
} }
} }
cfg := &paths.LocalStorageMeta{ cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"), Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"), CanSeal: cctx.Bool("seal"),

View File

@ -586,11 +586,11 @@ func (n *Ensemble) Start() *Ensemble {
psd := m.PresealDir psd := m.PresealDir
noPaths := m.options.noStorage noPaths := m.options.noStorage
err := lr.SetStorage(func(sc *paths.StorageConfig) { err := lr.SetStorage(func(sc *storiface.StorageConfig) {
if noPaths { if noPaths {
sc.StoragePaths = []paths.LocalPath{} sc.StoragePaths = []storiface.LocalPath{}
} }
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: psd}) sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{Path: psd})
}) })
require.NoError(n.t, err) require.NoError(n.t, err)
@ -737,8 +737,8 @@ func (n *Ensemble) Start() *Ensemble {
require.NoError(n.t, err) require.NoError(n.t, err)
if m.options.noStorage { if m.options.noStorage {
err := lr.SetStorage(func(sc *paths.StorageConfig) { err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = []paths.LocalPath{} sc.StoragePaths = []storiface.LocalPath{}
}) })
require.NoError(n.t, err) require.NoError(n.t, err)
} }

View File

@ -26,7 +26,6 @@ import (
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/wallet/key" "github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/miner" "github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline" sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -175,7 +174,7 @@ func (tm *TestMiner) FlushSealingBatches(ctx context.Context) {
const metaFile = "sectorstore.json" const metaFile = "sectorstore.json"
func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*paths.LocalStorageMeta)) storiface.ID { func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID {
p := t.TempDir() p := t.TempDir()
if err := os.MkdirAll(p, 0755); err != nil { if err := os.MkdirAll(p, 0755); err != nil {
@ -189,7 +188,7 @@ func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*pa
require.NoError(t, err) require.NoError(t, err)
} }
cfg := &paths.LocalStorageMeta{ cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: false, CanSeal: false,

View File

@ -15,7 +15,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -38,7 +37,7 @@ type TestWorker struct {
options nodeOpts options nodeOpts
} }
func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*paths.LocalStorageMeta)) storiface.ID { func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID {
p := t.TempDir() p := t.TempDir()
if err := os.MkdirAll(p, 0755); err != nil { if err := os.MkdirAll(p, 0755); err != nil {
@ -52,7 +51,7 @@ func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*p
require.NoError(t, err) require.NoError(t, err)
} }
cfg := &paths.LocalStorageMeta{ cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: false, CanSeal: false,

View File

@ -15,7 +15,6 @@ import (
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/sealtasks"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -74,7 +73,7 @@ func TestPathDetachRedeclare(t *testing.T) {
checkSectors(ctx, t, client, miner, 2, 2) checkSectors(ctx, t, client, miner, 2, 2)
// attach a new path // attach a new path
newId := miner.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) { newId := miner.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true cfg.CanStore = true
}) })
@ -194,7 +193,7 @@ func TestPathDetachRedeclareWorker(t *testing.T) {
checkSectors(ctx, t, client, miner, 2, 2) checkSectors(ctx, t, client, miner, 2, 2)
// attach a new path // attach a new path
newId := sealw.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) { newId := sealw.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true cfg.CanStore = true
}) })
@ -239,7 +238,7 @@ func TestPathDetachRedeclareWorker(t *testing.T) {
require.Len(t, local, 0) require.Len(t, local, 0)
// add a new one again, and move the sectors there // add a new one again, and move the sectors there
newId = sealw.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) { newId = sealw.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true cfg.CanStore = true
}) })

View File

@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/sealtasks"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -45,7 +44,7 @@ func TestPathTypeFilters(t *testing.T) {
} }
runTest(t, "invalid-type-alert", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) { runTest(t, "invalid-type-alert", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) {
slU := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { slU := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanSeal = true meta.CanSeal = true
meta.AllowTypes = []string{"unsealed", "seeled"} meta.AllowTypes = []string{"unsealed", "seeled"}
}) })
@ -79,18 +78,18 @@ func TestPathTypeFilters(t *testing.T) {
runTest(t, "seal-to-stor-unseal-allowdeny", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) { runTest(t, "seal-to-stor-unseal-allowdeny", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) {
// allow all types in the sealing path // allow all types in the sealing path
sealScratch := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { sealScratch := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanSeal = true meta.CanSeal = true
}) })
// unsealed storage // unsealed storage
unsStor := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { unsStor := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.AllowTypes = []string{"unsealed"} meta.AllowTypes = []string{"unsealed"}
}) })
// other storage // other storage
sealStor := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { sealStor := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.DenyTypes = []string{"unsealed"} meta.DenyTypes = []string{"unsealed"}
}) })
@ -115,14 +114,14 @@ func TestPathTypeFilters(t *testing.T) {
runTest(t, "sealstor-unseal-allowdeny", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) { runTest(t, "sealstor-unseal-allowdeny", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) {
// unsealed storage // unsealed storage
unsStor := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { unsStor := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.CanSeal = true meta.CanSeal = true
meta.AllowTypes = []string{"unsealed"} meta.AllowTypes = []string{"unsealed"}
}) })
// other storage // other storage
sealStor := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { sealStor := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.CanSeal = true meta.CanSeal = true
meta.DenyTypes = []string{"unsealed"} meta.DenyTypes = []string{"unsealed"}
@ -147,29 +146,29 @@ func TestPathTypeFilters(t *testing.T) {
runTest(t, "seal-store-allseparate", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) { runTest(t, "seal-store-allseparate", func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func()) {
// sealing stores // sealing stores
slU := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { slU := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanSeal = true meta.CanSeal = true
meta.AllowTypes = []string{"unsealed"} meta.AllowTypes = []string{"unsealed"}
}) })
slS := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { slS := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanSeal = true meta.CanSeal = true
meta.AllowTypes = []string{"sealed"} meta.AllowTypes = []string{"sealed"}
}) })
slC := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { slC := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanSeal = true meta.CanSeal = true
meta.AllowTypes = []string{"cache"} meta.AllowTypes = []string{"cache"}
}) })
// storage stores // storage stores
stU := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { stU := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.AllowTypes = []string{"unsealed"} meta.AllowTypes = []string{"unsealed"}
}) })
stS := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { stS := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.AllowTypes = []string{"sealed"} meta.AllowTypes = []string{"sealed"}
}) })
stC := miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { stC := miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.CanStore = true meta.CanStore = true
meta.AllowTypes = []string{"cache"} meta.AllowTypes = []string{"cache"}
}) })

View File

@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
func TestDealsWithFinalizeEarly(t *testing.T) { func TestDealsWithFinalizeEarly(t *testing.T) {
@ -36,11 +36,11 @@ func TestDealsWithFinalizeEarly(t *testing.T) {
ctx := context.Background() ctx := context.Background()
miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.Weight = 1000000000 meta.Weight = 1000000000
meta.CanSeal = true meta.CanSeal = true
}) })
miner.AddStorage(ctx, t, func(meta *paths.LocalStorageMeta) { miner.AddStorage(ctx, t, func(meta *storiface.LocalStorageMeta) {
meta.Weight = 1000000000 meta.Weight = 1000000000
meta.CanStore = true meta.CanStore = true
}) })

View File

@ -894,7 +894,7 @@ If you see stuck Finalize tasks after enabling this setting, check
}, },
{ {
Name: "ResourceFiltering", Name: "ResourceFiltering",
Type: "sealer.ResourceFilteringStrategy", Type: "ResourceFilteringStrategy",
Comment: `ResourceFiltering instructs the system which resource filtering strategy Comment: `ResourceFiltering instructs the system which resource filtering strategy
to use when evaluating tasks against this worker. An empty value defaults to use when evaluating tasks against this worker. An empty value defaults

View File

@ -8,10 +8,10 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
func StorageFromFile(path string, def *paths.StorageConfig) (*paths.StorageConfig, error) { func StorageFromFile(path string, def *storiface.StorageConfig) (*storiface.StorageConfig, error) {
file, err := os.Open(path) file, err := os.Open(path)
switch { switch {
case os.IsNotExist(err): case os.IsNotExist(err):
@ -27,8 +27,8 @@ func StorageFromFile(path string, def *paths.StorageConfig) (*paths.StorageConfi
return StorageFromReader(file) return StorageFromReader(file)
} }
func StorageFromReader(reader io.Reader) (*paths.StorageConfig, error) { func StorageFromReader(reader io.Reader) (*storiface.StorageConfig, error) {
var cfg paths.StorageConfig var cfg storiface.StorageConfig
err := json.NewDecoder(reader).Decode(&cfg) err := json.NewDecoder(reader).Decode(&cfg)
if err != nil { if err != nil {
return nil, err return nil, err
@ -37,7 +37,7 @@ func StorageFromReader(reader io.Reader) (*paths.StorageConfig, error) {
return &cfg, nil return &cfg, nil
} }
func WriteStorageFile(path string, config paths.StorageConfig) error { func WriteStorageFile(path string, config storiface.StorageConfig) error {
b, err := json.MarshalIndent(config, "", " ") b, err := json.MarshalIndent(config, "", " ")
if err != nil { if err != nil {
return xerrors.Errorf("marshaling storage config: %w", err) return xerrors.Errorf("marshaling storage config: %w", err)

View File

@ -25,8 +25,8 @@ import (
badgerbs "github.com/filecoin-project/lotus/blockstore/badger" badgerbs "github.com/filecoin-project/lotus/blockstore/badger"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
const ( const (
@ -572,26 +572,26 @@ func (fsr *fsLockedRepo) SetConfig(c func(interface{})) error {
return nil return nil
} }
func (fsr *fsLockedRepo) GetStorage() (paths.StorageConfig, error) { func (fsr *fsLockedRepo) GetStorage() (storiface.StorageConfig, error) {
fsr.storageLk.Lock() fsr.storageLk.Lock()
defer fsr.storageLk.Unlock() defer fsr.storageLk.Unlock()
return fsr.getStorage(nil) return fsr.getStorage(nil)
} }
func (fsr *fsLockedRepo) getStorage(def *paths.StorageConfig) (paths.StorageConfig, error) { func (fsr *fsLockedRepo) getStorage(def *storiface.StorageConfig) (storiface.StorageConfig, error) {
c, err := config.StorageFromFile(fsr.join(fsStorageConfig), def) c, err := config.StorageFromFile(fsr.join(fsStorageConfig), def)
if err != nil { if err != nil {
return paths.StorageConfig{}, err return storiface.StorageConfig{}, err
} }
return *c, nil return *c, nil
} }
func (fsr *fsLockedRepo) SetStorage(c func(*paths.StorageConfig)) error { func (fsr *fsLockedRepo) SetStorage(c func(*storiface.StorageConfig)) error {
fsr.storageLk.Lock() fsr.storageLk.Lock()
defer fsr.storageLk.Unlock() defer fsr.storageLk.Unlock()
sc, err := fsr.getStorage(&paths.StorageConfig{}) sc, err := fsr.getStorage(&storiface.StorageConfig{})
if err != nil { if err != nil {
return xerrors.Errorf("get storage: %w", err) return xerrors.Errorf("get storage: %w", err)
} }

View File

@ -9,8 +9,8 @@ import (
"github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
// BlockstoreDomain represents the domain of a blockstore. // BlockstoreDomain represents the domain of a blockstore.
@ -73,8 +73,8 @@ type LockedRepo interface {
Config() (interface{}, error) Config() (interface{}, error)
SetConfig(func(interface{})) error SetConfig(func(interface{})) error
GetStorage() (paths.StorageConfig, error) GetStorage() (storiface.StorageConfig, error)
SetStorage(func(*paths.StorageConfig)) error SetStorage(func(*storiface.StorageConfig)) error
Stat(path string) (fsutil.FsStat, error) Stat(path string) (fsutil.FsStat, error)
DiskUsage(path string) (int64, error) DiskUsage(path string) (int64, error)

View File

@ -18,7 +18,6 @@ import (
"github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -37,7 +36,7 @@ type MemRepo struct {
keystore map[string]types.KeyInfo keystore map[string]types.KeyInfo
blockstore blockstore.Blockstore blockstore blockstore.Blockstore
sc *paths.StorageConfig sc *storiface.StorageConfig
tempDir string tempDir string
// holds the current config value // holds the current config value
@ -59,13 +58,13 @@ func (lmem *lockedMemRepo) RepoType() RepoType {
return lmem.t return lmem.t
} }
func (lmem *lockedMemRepo) GetStorage() (paths.StorageConfig, error) { func (lmem *lockedMemRepo) GetStorage() (storiface.StorageConfig, error) {
if err := lmem.checkToken(); err != nil { if err := lmem.checkToken(); err != nil {
return paths.StorageConfig{}, err return storiface.StorageConfig{}, err
} }
if lmem.mem.sc == nil { if lmem.mem.sc == nil {
lmem.mem.sc = &paths.StorageConfig{StoragePaths: []paths.LocalPath{ lmem.mem.sc = &storiface.StorageConfig{StoragePaths: []storiface.LocalPath{
{Path: lmem.Path()}, {Path: lmem.Path()},
}} }}
} }
@ -73,7 +72,7 @@ func (lmem *lockedMemRepo) GetStorage() (paths.StorageConfig, error) {
return *lmem.mem.sc, nil return *lmem.mem.sc, nil
} }
func (lmem *lockedMemRepo) SetStorage(c func(*paths.StorageConfig)) error { func (lmem *lockedMemRepo) SetStorage(c func(*storiface.StorageConfig)) error {
if err := lmem.checkToken(); err != nil { if err := lmem.checkToken(); err != nil {
return err return err
} }
@ -126,14 +125,14 @@ func (lmem *lockedMemRepo) Path() string {
} }
func (lmem *lockedMemRepo) initSectorStore(t string) { func (lmem *lockedMemRepo) initSectorStore(t string) {
if err := config.WriteStorageFile(filepath.Join(t, fsStorageConfig), paths.StorageConfig{ if err := config.WriteStorageFile(filepath.Join(t, fsStorageConfig), storiface.StorageConfig{
StoragePaths: []paths.LocalPath{ StoragePaths: []storiface.LocalPath{
{Path: t}, {Path: t},
}}); err != nil { }}); err != nil {
panic(err) panic(err)
} }
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: true, CanSeal: true,

View File

@ -21,67 +21,9 @@ import (
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
// LocalStorageMeta [path]/sectorstore.json
type LocalStorageMeta struct {
ID storiface.ID
// A high weight means data is more likely to be stored in this path
Weight uint64 // 0 = readonly
// Intermediate data for the sealing process will be stored here
CanSeal bool
// Finalized sectors that will be proved over time will be stored here
CanStore bool
// MaxStorage specifies the maximum number of bytes to use for sector storage
// (0 = unlimited)
MaxStorage uint64
// List of storage groups this path belongs to
Groups []string
// List of storage groups to which data from this path can be moved. If none
// are specified, allow to all
AllowTo []string
// AllowTypes lists sector file types which are allowed to be put into this
// path. If empty, all file types are allowed.
//
// Valid values:
// - "unsealed"
// - "sealed"
// - "cache"
// - "update"
// - "update-cache"
// Any other value will generate a warning and be ignored.
AllowTypes []string
// DenyTypes lists sector file types which aren't allowed to be put into this
// path.
//
// Valid values:
// - "unsealed"
// - "sealed"
// - "cache"
// - "update"
// - "update-cache"
// Any other value will generate a warning and be ignored.
DenyTypes []string
}
// StorageConfig .lotusstorage/storage.json
type StorageConfig struct {
StoragePaths []LocalPath
}
type LocalPath struct {
Path string
}
type LocalStorage interface { type LocalStorage interface {
GetStorage() (StorageConfig, error) GetStorage() (storiface.StorageConfig, error)
SetStorage(func(*StorageConfig)) error SetStorage(func(*storiface.StorageConfig)) error
Stat(path string) (fsutil.FsStat, error) Stat(path string) (fsutil.FsStat, error)
@ -213,7 +155,7 @@ func (st *Local) OpenPath(ctx context.Context, p string) error {
return xerrors.Errorf("reading storage metadata for %s: %w", p, err) return xerrors.Errorf("reading storage metadata for %s: %w", p, err)
} }
var meta LocalStorageMeta var meta storiface.LocalStorageMeta
if err := json.Unmarshal(mb, &meta); err != nil { if err := json.Unmarshal(mb, &meta); err != nil {
return xerrors.Errorf("unmarshalling storage metadata for %s: %w", p, err) return xerrors.Errorf("unmarshalling storage metadata for %s: %w", p, err)
} }
@ -309,7 +251,7 @@ func (st *Local) Redeclare(ctx context.Context, filterId *storiface.ID, dropMiss
return xerrors.Errorf("reading storage metadata for %s: %w", p.local, err) return xerrors.Errorf("reading storage metadata for %s: %w", p.local, err)
} }
var meta LocalStorageMeta var meta storiface.LocalStorageMeta
if err := json.Unmarshal(mb, &meta); err != nil { if err := json.Unmarshal(mb, &meta); err != nil {
return xerrors.Errorf("unmarshalling storage metadata for %s: %w", p.local, err) return xerrors.Errorf("unmarshalling storage metadata for %s: %w", p.local, err)
} }

View File

@ -19,18 +19,18 @@ const pathSize = 16 << 20
type TestingLocalStorage struct { type TestingLocalStorage struct {
root string root string
c StorageConfig c storiface.StorageConfig
} }
func (t *TestingLocalStorage) DiskUsage(path string) (int64, error) { func (t *TestingLocalStorage) DiskUsage(path string) (int64, error) {
return 1, nil return 1, nil
} }
func (t *TestingLocalStorage) GetStorage() (StorageConfig, error) { func (t *TestingLocalStorage) GetStorage() (storiface.StorageConfig, error) {
return t.c, nil return t.c, nil
} }
func (t *TestingLocalStorage) SetStorage(f func(*StorageConfig)) error { func (t *TestingLocalStorage) SetStorage(f func(*storiface.StorageConfig)) error {
f(&t.c) f(&t.c)
return nil return nil
} }
@ -51,7 +51,7 @@ func (t *TestingLocalStorage) init(subpath string) error {
metaFile := filepath.Join(path, MetaFile) metaFile := filepath.Join(path, MetaFile)
meta := &LocalStorageMeta{ meta := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 1, Weight: 1,
CanSeal: true, CanSeal: true,

View File

@ -7,6 +7,7 @@ import (
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
var StatTimeout = 5 * time.Second var StatTimeout = 5 * time.Second
@ -47,11 +48,11 @@ type diskUsageResult struct {
time time.Time time time.Time
} }
func (c *cachedLocalStorage) GetStorage() (StorageConfig, error) { func (c *cachedLocalStorage) GetStorage() (storiface.StorageConfig, error) {
return c.base.GetStorage() return c.base.GetStorage()
} }
func (c *cachedLocalStorage) SetStorage(f func(*StorageConfig)) error { func (c *cachedLocalStorage) SetStorage(f func(*storiface.StorageConfig)) error {
return c.base.SetStorage(f) return c.base.SetStorage(f)
} }

View File

@ -38,7 +38,7 @@ func createTestStorage(t *testing.T, p string, seal bool, att ...*paths.Local) s
} }
} }
cfg := &paths.LocalStorageMeta{ cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: seal, CanSeal: seal,
@ -77,8 +77,8 @@ func TestMoveShared(t *testing.T) {
_ = lr.Close() _ = lr.Close()
}) })
err = lr.SetStorage(func(config *paths.StorageConfig) { err = lr.SetStorage(func(config *storiface.StorageConfig) {
*config = paths.StorageConfig{} *config = storiface.StorageConfig{}
}) })
require.NoError(t, err) require.NoError(t, err)

View File

@ -3,7 +3,6 @@ package sealer
import ( import (
"context" "context"
"errors" "errors"
"github.com/filecoin-project/lotus/node/config"
"io" "io"
"net/http" "net/http"
"sort" "sort"
@ -20,6 +19,7 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-statestore" "github.com/filecoin-project/go-statestore"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/fsutil"
@ -191,8 +191,8 @@ func (m *Manager) AddLocalStorage(ctx context.Context, path string) error {
return xerrors.Errorf("opening local path: %w", err) return xerrors.Errorf("opening local path: %w", err)
} }
if err := m.ls.SetStorage(func(sc *paths.StorageConfig) { if err := m.ls.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: path}) sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{Path: path})
}); err != nil { }); err != nil {
return xerrors.Errorf("get storage config: %w", err) return xerrors.Errorf("get storage config: %w", err)
} }
@ -225,8 +225,8 @@ func (m *Manager) DetachLocalStorage(ctx context.Context, path string) error {
// drop from the persisted storage.json // drop from the persisted storage.json
var found bool var found bool
if err := m.ls.SetStorage(func(sc *paths.StorageConfig) { if err := m.ls.SetStorage(func(sc *storiface.StorageConfig) {
out := make([]paths.LocalPath, 0, len(sc.StoragePaths)) out := make([]storiface.LocalPath, 0, len(sc.StoragePaths))
for _, storagePath := range sc.StoragePaths { for _, storagePath := range sc.StoragePaths {
if storagePath.Path != path { if storagePath.Path != path {
out = append(out, storagePath) out = append(out, storagePath)

View File

@ -39,7 +39,7 @@ func init() {
logging.SetAllLoggers(logging.LevelDebug) logging.SetAllLoggers(logging.LevelDebug)
} }
type testStorage paths.StorageConfig type testStorage storiface.StorageConfig
func (t testStorage) DiskUsage(path string) (int64, error) { func (t testStorage) DiskUsage(path string) (int64, error) {
return 1, nil // close enough return 1, nil // close enough
@ -50,7 +50,7 @@ func newTestStorage(t *testing.T) *testStorage {
require.NoError(t, err) require.NoError(t, err)
{ {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 1, Weight: 1,
CanSeal: true, CanSeal: true,
@ -63,7 +63,7 @@ func newTestStorage(t *testing.T) *testStorage {
} }
return &testStorage{ return &testStorage{
StoragePaths: []paths.LocalPath{ StoragePaths: []storiface.LocalPath{
{Path: tp}, {Path: tp},
}, },
} }
@ -82,12 +82,12 @@ func (t testStorage) cleanup() {
} }
} }
func (t testStorage) GetStorage() (paths.StorageConfig, error) { func (t testStorage) GetStorage() (storiface.StorageConfig, error) {
return paths.StorageConfig(t), nil return storiface.StorageConfig(t), nil
} }
func (t *testStorage) SetStorage(f func(*paths.StorageConfig)) error { func (t *testStorage) SetStorage(f func(*storiface.StorageConfig)) error {
f((*paths.StorageConfig)(t)) f((*storiface.StorageConfig)(t))
return nil return nil
} }

View File

@ -153,3 +153,61 @@ type SecDataHttpHeader struct {
Key string Key string
Value string Value string
} }
// StorageConfig .lotusstorage/storage.json
type StorageConfig struct {
StoragePaths []LocalPath
}
type LocalPath struct {
Path string
}
// LocalStorageMeta [path]/sectorstore.json
type LocalStorageMeta struct {
ID ID
// A high weight means data is more likely to be stored in this path
Weight uint64 // 0 = readonly
// Intermediate data for the sealing process will be stored here
CanSeal bool
// Finalized sectors that will be proved over time will be stored here
CanStore bool
// MaxStorage specifies the maximum number of bytes to use for sector storage
// (0 = unlimited)
MaxStorage uint64
// List of storage groups this path belongs to
Groups []string
// List of storage groups to which data from this path can be moved. If none
// are specified, allow to all
AllowTo []string
// AllowTypes lists sector file types which are allowed to be put into this
// path. If empty, all file types are allowed.
//
// Valid values:
// - "unsealed"
// - "sealed"
// - "cache"
// - "update"
// - "update-cache"
// Any other value will generate a warning and be ignored.
AllowTypes []string
// DenyTypes lists sector file types which aren't allowed to be put into this
// path.
//
// Valid values:
// - "unsealed"
// - "sealed"
// - "cache"
// - "update"
// - "update-cache"
// Any other value will generate a warning and be ignored.
DenyTypes []string
}

View File

@ -40,7 +40,6 @@ import (
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/impl" "github.com/filecoin-project/lotus/node/impl"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline" sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
@ -198,9 +197,9 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
} }
} }
var localPaths []paths.LocalPath var localPaths []storiface.LocalPath
b, err := json.MarshalIndent(&paths.LocalStorageMeta{ b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()), ID: storiface.ID(uuid.New().String()),
Weight: 10, Weight: 10,
CanSeal: true, CanSeal: true,
@ -214,11 +213,11 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
return nil, fmt.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) return nil, fmt.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
} }
localPaths = append(localPaths, paths.LocalPath{ localPaths = append(localPaths, storiface.LocalPath{
Path: lr.Path(), Path: lr.Path(),
}) })
if err := lr.SetStorage(func(sc *paths.StorageConfig) { if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...) sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil { }); err != nil {
return nil, err return nil, err