get it compiling

This commit is contained in:
aarshkshah1992
2021-07-20 21:44:25 +05:30
parent 44496afc66
commit 0c90868929
5 changed files with 30 additions and 37 deletions
+4 -4
View File
@@ -808,14 +808,14 @@ func (a *API) clientRetrieve(ctx context.Context, order api.RetrievalOrder, ref
}
if rs.IsIPFSRetrieval() {
// write out the CARv1 blocks of the CARv2 file to the IPFS blockstore.
carv2Reader, err := carv2.NewReaderMmap(carV2FilePath)
carv2Reader, err := carv2.OpenReader(carV2FilePath)
if err != nil {
finish(err)
return
}
defer carv2Reader.Close() //nolint:errcheck
if _, err := car.LoadCar(rs.Blockstore(), carv2Reader.CarV1Reader()); err != nil {
if _, err := car.LoadCar(rs.Blockstore(), carv2Reader.DataReader()); err != nil {
finish(err)
return
}
@@ -835,13 +835,13 @@ func (a *API) clientRetrieve(ctx context.Context, order api.RetrievalOrder, ref
return
}
carv2Reader, err := carv2.NewReaderMmap(carV2FilePath)
carv2Reader, err := carv2.OpenReader(carV2FilePath)
if err != nil {
finish(err)
return
}
defer carv2Reader.Close() //nolint:errcheck
if _, err := io.Copy(f, carv2Reader.CarV1Reader()); err != nil {
if _, err := io.Copy(f, carv2Reader.DataReader()); err != nil {
finish(err)
return
}
+5 -14
View File
@@ -16,7 +16,6 @@ import (
dtgstransport "github.com/filecoin-project/go-data-transfer/transport/graphsync"
"github.com/filecoin-project/go-fil-markets/discovery"
discoveryimpl "github.com/filecoin-project/go-fil-markets/discovery/impl"
"github.com/filecoin-project/go-fil-markets/filestore"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
retrievalimpl "github.com/filecoin-project/go-fil-markets/retrievalmarket/impl"
rmnet "github.com/filecoin-project/go-fil-markets/retrievalmarket/network"
@@ -183,15 +182,16 @@ func StorageClient(lc fx.Lifecycle, h host.Host, dataTransfer dtypes.ClientDataT
func RetrievalClient(lc fx.Lifecycle, h host.Host, r repo.LockedRepo, dt dtypes.ClientDataTransfer, payAPI payapi.PaychAPI, resolver discovery.PeerResolver,
ds dtypes.MetadataDS, chainAPI full.ChainAPI, stateAPI full.StateAPI, j journal.Journal) (retrievalmarket.RetrievalClient, error) {
carStore, err := getRetrievalCarStore(r.Path())
if err != nil {
return nil, err
carsPath := filepath.Join(r.Path(), dagStore, "retrieval-cars")
if err := os.MkdirAll(carsPath, 0755); err != nil {
return nil, xerrors.Errorf("failed to create dir")
}
adapter := retrievaladapter.NewRetrievalClientNode(payAPI, chainAPI, stateAPI)
network := rmnet.NewFromLibp2pHost(h)
client, err := retrievalimpl.NewClient(network,
carStore, dt, adapter, resolver, namespace.Wrap(ds, datastore.NewKey("/retrievals/client")))
carsPath, dt, adapter, resolver, namespace.Wrap(ds, datastore.NewKey("/retrievals/client")))
if err != nil {
return nil, err
}
@@ -209,15 +209,6 @@ func RetrievalClient(lc fx.Lifecycle, h host.Host, r repo.LockedRepo, dt dtypes.
return client, nil
}
func getRetrievalCarStore(path string) (filestore.CarFileStore, error) {
carStorePath := filepath.Join(path, "retrieval-cars")
err := os.Mkdir(carStorePath, os.ModePerm)
if err != nil {
return nil, xerrors.Errorf("could not create directory %s: %w", carStorePath, err)
}
return filestore.NewLocalCarStore(path)
}
// ClientBlockstoreRetrievalStoreManager is the default version of the RetrievalStoreManager that runs on multistore
func ClientBlockstoreRetrievalStoreManager(isIpfsRetrieval bool) func(bs dtypes.ClientBlockstore) (dtypes.ClientRetrievalStoreManager, error) {
return func(bs dtypes.ClientBlockstore) (dtypes.ClientRetrievalStoreManager, error) {
+8 -5
View File
@@ -77,6 +77,7 @@ import (
)
var StorageCounterDSPrefix = "/storage/nextid"
var dagStore = "dagStore"
func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) {
maddrb, err := ds.Get(datastore.NewKey("miner-address"))
@@ -582,7 +583,7 @@ func DagStoreWrapper(
pieceStore dtypes.ProviderPieceStore,
rpn retrievalmarket.RetrievalProviderNode,
) (*dagstore.Wrapper, error) {
dagStoreDir := filepath.Join(r.Path(), "dagstore")
dagStoreDir := filepath.Join(r.Path(), dagStore)
dagStoreDS := namespace.Wrap(ds, datastore.NewKey("/dagstore/provider"))
cfg := dagstore.MarketDAGStoreConfig{
TransientsDir: filepath.Join(dagStoreDir, "transients"),
@@ -616,7 +617,7 @@ func StorageProvider(minerAddress dtypes.MinerAddress,
dataTransfer dtypes.ProviderDataTransfer,
spn storagemarket.StorageProviderNode,
df dtypes.StorageDealFilter,
dagStore *dagstore.Wrapper,
dsw *dagstore.Wrapper,
) (storagemarket.StorageProvider, error) {
net := smnet.NewFromLibp2pHost(h)
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
@@ -624,10 +625,12 @@ func StorageProvider(minerAddress dtypes.MinerAddress,
return nil, err
}
opt := storageimpl.CustomDealDecisionLogic(storageimpl.DealDeciderFunc(df))
shardMigrator := storageimpl.NewShardMigrator(address.Address(minerAddress), ds, dagStore, pieceStore, spn)
dagStorePath := filepath.Join(r.Path(), dagStore)
return storageimpl.NewProvider(net, namespace.Wrap(ds, datastore.NewKey("/deals/provider")), store, dagStore, pieceStore,
opt := storageimpl.CustomDealDecisionLogic(storageimpl.DealDeciderFunc(df))
shardMigrator := storageimpl.NewShardMigrator(address.Address(minerAddress), dagStorePath, dsw, pieceStore, spn)
return storageimpl.NewProvider(net, namespace.Wrap(ds, datastore.NewKey("/deals/provider")), store, dsw, pieceStore,
dataTransfer, spn, address.Address(minerAddress), storedAsk, shardMigrator, opt)
}