Client Import manager
This commit is contained in:
@@ -34,9 +34,25 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/node/repo/importmgr"
|
||||
"github.com/filecoin-project/lotus/paychmgr"
|
||||
)
|
||||
|
||||
func ClientMultiDatastore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.ClientMultiDstore, error) {
|
||||
mds, err := importmgr.NewMultiDstore(r, "/client")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lc.Append(fx.Hook{
|
||||
OnStop: func(ctx context.Context) error {
|
||||
return mds.Close()
|
||||
},
|
||||
})
|
||||
|
||||
return mds, nil
|
||||
}
|
||||
|
||||
func ClientFstore(r repo.LockedRepo) (dtypes.ClientFilestore, error) {
|
||||
clientds, err := r.Datastore("/client")
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dtypes
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation"
|
||||
bserv "github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-filestore"
|
||||
@@ -10,9 +9,12 @@ import (
|
||||
exchange "github.com/ipfs/go-ipfs-exchange-interface"
|
||||
format "github.com/ipfs/go-ipld-format"
|
||||
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation"
|
||||
|
||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||
"github.com/filecoin-project/go-fil-markets/piecestore"
|
||||
"github.com/filecoin-project/go-statestore"
|
||||
"github.com/filecoin-project/lotus/node/repo/importmgr"
|
||||
)
|
||||
|
||||
// MetadataDS stores metadata
|
||||
@@ -26,9 +28,9 @@ type ChainGCBlockstore blockstore.GCBlockstore
|
||||
type ChainExchange exchange.Interface
|
||||
type ChainBlockService bserv.BlockService
|
||||
|
||||
type ClientMultiDstore *importmgr.MultiStore
|
||||
type ClientFilestore *filestore.Filestore
|
||||
type ClientBlockstore blockstore.Blockstore
|
||||
type ClientDAG format.DAGService
|
||||
type ClientDealStore *statestore.StateStore
|
||||
type ClientRequestValidator *requestvalidation.UnifiedRequestValidator
|
||||
type ClientDatastore datastore.Batching
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-datastore"
|
||||
dsync "github.com/ipfs/go-datastore/sync"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
offline "github.com/ipfs/go-ipfs-exchange-offline"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
"github.com/ipfs/go-merkledag"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
func MapBlockstore() blockstore.Blockstore {
|
||||
// TODO: proper datastore
|
||||
bds := dsync.MutexWrap(datastore.NewMapDatastore())
|
||||
bs := blockstore.NewBlockstore(bds)
|
||||
return blockstore.NewIdStore(bs)
|
||||
}
|
||||
|
||||
func MapDatastore() datastore.Batching {
|
||||
return dsync.MutexWrap(datastore.NewMapDatastore())
|
||||
}
|
||||
|
||||
func MemoryClientDag(lc fx.Lifecycle) ipld.DAGService {
|
||||
ibs := blockstore.NewBlockstore(datastore.NewMapDatastore())
|
||||
bsvc := blockservice.New(ibs, offline.Exchange(ibs))
|
||||
dag := merkledag.NewDAGService(bsvc)
|
||||
|
||||
lc.Append(fx.Hook{
|
||||
OnStop: func(_ context.Context) error {
|
||||
return bsvc.Close()
|
||||
},
|
||||
})
|
||||
|
||||
return dag
|
||||
}
|
||||
Reference in New Issue
Block a user