Merge pull request #1049 from filecoin-project/fix/sb-ds-prefix

Pass correct datastore into sectorbuilder
This commit is contained in:
Jakub Sztandera 2020-01-09 15:33:15 +01:00 committed by GitHub
commit f572d9735d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 13 deletions

View File

@ -8,6 +8,8 @@ import (
"encoding/json" "encoding/json"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder" sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
badger "github.com/ipfs/go-ds-badger" badger "github.com/ipfs/go-ds-badger"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
@ -196,7 +198,7 @@ var aggregateSectorDirsCmd = &cli.Command{
SectorSize: ssize, SectorSize: ssize,
Dir: destdir, Dir: destdir,
WorkerThreads: 2, WorkerThreads: 2,
}, agmds) }, namespace.Wrap(agmds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return err return err
} }
@ -257,7 +259,7 @@ var aggregateSectorDirsCmd = &cli.Command{
SectorSize: genm.SectorSize, SectorSize: genm.SectorSize,
Dir: dir, Dir: dir,
WorkerThreads: 2, WorkerThreads: 2,
}, mds) }, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return err return err
} }

View File

@ -11,6 +11,8 @@ import (
"path/filepath" "path/filepath"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder" sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
badger "github.com/ipfs/go-ds-badger" badger "github.com/ipfs/go-ds-badger"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -43,7 +45,7 @@ func PreSeal(maddr address.Address, ssize uint64, offset uint64, sectors int, sb
return nil, err return nil, err
} }
sb, err := sectorbuilder.New(cfg, mds) sb, err := sectorbuilder.New(cfg, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -13,6 +13,7 @@ import (
paramfetch "github.com/filecoin-project/go-paramfetch" paramfetch "github.com/filecoin-project/go-paramfetch"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
badger "github.com/ipfs/go-ds-badger" badger "github.com/ipfs/go-ds-badger"
"github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
@ -174,7 +175,7 @@ var initCmd = &cli.Command{
SectorSize: ssize, SectorSize: ssize,
WorkerThreads: 2, WorkerThreads: 2,
Dir: pssb, Dir: pssb,
}, oldmds) }, namespace.Wrap(oldmds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return xerrors.Errorf("failed to open up preseal sectorbuilder: %w", err) return xerrors.Errorf("failed to open up preseal sectorbuilder: %w", err)
} }
@ -183,7 +184,7 @@ var initCmd = &cli.Command{
SectorSize: ssize, SectorSize: ssize,
WorkerThreads: 2, WorkerThreads: 2,
Dir: lr.Path(), Dir: lr.Path(),
}, mds) }, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return xerrors.Errorf("failed to open up sectorbuilder: %w", err) return xerrors.Errorf("failed to open up sectorbuilder: %w", err)
} }

View File

@ -206,7 +206,7 @@ func SetupBlockProducer(lc fx.Lifecycle, ds dtypes.MetadataDS, api api.FullNode,
} }
func SectorBuilder(cfg *sectorbuilder.Config, ds dtypes.MetadataDS) (*sectorbuilder.SectorBuilder, error) { func SectorBuilder(cfg *sectorbuilder.Config, ds dtypes.MetadataDS) (*sectorbuilder.SectorBuilder, error) {
sb, err := sectorbuilder.New(cfg, ds) sb, err := sectorbuilder.New(cfg, namespace.Wrap(ds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -9,20 +9,18 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/go-address"
"github.com/libp2p/go-libp2p-core/crypto"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder" sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/lotus/build"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
badger "github.com/ipfs/go-ds-badger" badger "github.com/ipfs/go-ds-badger"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/client" "github.com/filecoin-project/lotus/api/client"
"github.com/filecoin-project/lotus/api/test" "github.com/filecoin-project/lotus/api/test"
@ -231,7 +229,7 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
WorkerThreads: 2, WorkerThreads: 2,
Miner: genMiner, Miner: genMiner,
Dir: psd, Dir: psd,
}, mds) }, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder")))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }