diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 42abae157..232893f9d 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -369,7 +369,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, return err } - sbcfg, err := modules.SectorBuilderConfig(lr.Path(), 2, false, false)(mds, api) + sbcfg, err := modules.SectorBuilderConfig(sectorbuilder.SimplePath(lr.Path()), 2, false, false)(mds, api) if err != nil { return xerrors.Errorf("getting genesis miner sector builder config: %w", err) } diff --git a/node/builder.go b/node/builder.go index 5ec6e4183..028778c09 100644 --- a/node/builder.go +++ b/node/builder.go @@ -7,6 +7,7 @@ import ( sectorbuilder "github.com/filecoin-project/go-sectorbuilder" blockstore "github.com/ipfs/go-ipfs-blockstore" + logging "github.com/ipfs/go-log" ci "github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/peer" @@ -54,6 +55,8 @@ import ( "github.com/filecoin-project/lotus/storage/sectorblocks" ) +var log = logging.Logger("builder") + // special is a type used to give keys to modules which // can't really be identified by the returned type type special struct{ id int } @@ -342,15 +345,20 @@ func ConfigStorageMiner(c interface{}, lr repo.LockedRepo) Option { return Error(xerrors.Errorf("invalid config from repo, got: %T", c)) } - path := cfg.SectorBuilder.Path - if path == "" { - path = lr.Path() + scfg := sectorbuilder.SimplePath(lr.Path()) + if cfg.SectorBuilder.Path == "" { + if len(cfg.SectorBuilder.Storage) > 0 { + scfg = cfg.SectorBuilder.Storage + } + } else { + scfg = sectorbuilder.SimplePath(cfg.SectorBuilder.Path) + log.Warn("LEGACY SectorBuilder.Path FOUND IN CONFIG. Please use the new storage config") } return Options( ConfigCommon(&cfg.Common), - Override(new(*sectorbuilder.Config), modules.SectorBuilderConfig(path, + Override(new(*sectorbuilder.Config), modules.SectorBuilderConfig(scfg, cfg.SectorBuilder.WorkerCount, cfg.SectorBuilder.DisableLocalPreCommit, cfg.SectorBuilder.DisableLocalCommit)), diff --git a/node/config/def.go b/node/config/def.go index 97ed036d5..43007b684 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -3,6 +3,8 @@ package config import ( "encoding" "time" + + "github.com/filecoin-project/go-sectorbuilder/fs" ) // Common is common config between full node and miner @@ -54,7 +56,8 @@ type Metrics struct { // // Storage Miner type SectorBuilder struct { - Path string + Path string // TODO: remove // FORK (-ish) + Storage []fs.PathConfig WorkerCount uint DisableLocalPreCommit bool diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index e2c1b44c0..8981b10c3 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -14,6 +14,7 @@ import ( storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl" paramfetch "github.com/filecoin-project/go-paramfetch" "github.com/filecoin-project/go-sectorbuilder" + "github.com/filecoin-project/go-sectorbuilder/fs" "github.com/filecoin-project/go-statestore" "github.com/ipfs/go-bitswap" "github.com/ipfs/go-bitswap/network" @@ -62,7 +63,7 @@ func GetParams(sbc *sectorbuilder.Config) error { return nil } -func SectorBuilderConfig(storagePath string, threads uint, noprecommit, nocommit bool) func(dtypes.MetadataDS, api.FullNode) (*sectorbuilder.Config, error) { +func SectorBuilderConfig(storage []fs.PathConfig, threads uint, noprecommit, nocommit bool) func(dtypes.MetadataDS, api.FullNode) (*sectorbuilder.Config, error) { return func(ds dtypes.MetadataDS, api api.FullNode) (*sectorbuilder.Config, error) { minerAddr, err := minerAddrFromDS(ds) if err != nil { @@ -74,9 +75,11 @@ func SectorBuilderConfig(storagePath string, threads uint, noprecommit, nocommit return nil, err } - sp, err := homedir.Expand(storagePath) - if err != nil { - return nil, err + for i := range storage { + storage[i].Path, err = homedir.Expand(storage[i].Path) + if err != nil { + return nil, err + } } if threads > math.MaxUint8 { @@ -91,7 +94,7 @@ func SectorBuilderConfig(storagePath string, threads uint, noprecommit, nocommit NoPreCommit: noprecommit, NoCommit: nocommit, - Paths: sectorbuilder.SimplePath(sp), + Paths: storage, } return sb, nil