Skip to content

Commit

Permalink
Do not create CAR file when propsing a storage deal using Manual Tran…
Browse files Browse the repository at this point in the history
…sfer (#183)
  • Loading branch information
arajasek authored Apr 6, 2020
1 parent 473c5d1 commit 412b34d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions storagemarket/impl/clientutils/clientutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func CommP(ctx context.Context, pieceIO pieceio.PieceIO, rt abi.RegisteredProof,
if data.PieceCid != nil {
return *data.PieceCid, data.PieceSize, nil
}

if data.TransferType == storagemarket.TTManual {
return cid.Undef, 0, xerrors.New("Piece CID and size must be set for manual transfer")
}
ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())

// entire DAG selector
Expand Down
16 changes: 14 additions & 2 deletions storagemarket/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package storagemarket_test
import (
"bytes"
"context"
"github.com/filecoin-project/go-fil-markets/pieceio"
"io/ioutil"
"reflect"
"testing"
Expand Down Expand Up @@ -201,6 +202,19 @@ func TestMakeDealOffline(t *testing.T) {
TransferType: storagemarket.TTManual,
Root: payloadCid,
}

carBuf := new(bytes.Buffer)

err = cario.NewCarIO().WriteCar(ctx, td.Bs1, payloadCid, td.AllSelector, carBuf)
require.NoError(t, err)

commP, size, err := pieceio.GeneratePieceCommitment(abi.RegisteredProof_StackedDRG2KiBPoSt, carBuf, uint64(carBuf.Len()))

assert.NoError(t, err)

dataRef.PieceCid = &commP
dataRef.PieceSize = size

result, err := client.ProposeStorageDeal(ctx, providerAddr, &providerInfo, dataRef, abi.ChainEpoch(epoch+100), abi.ChainEpoch(epoch+20100), big.NewInt(1), big.NewInt(0), abi.RegisteredProof_StackedDRG2KiBPoSt)
assert.NoError(t, err)

Expand All @@ -219,8 +233,6 @@ func TestMakeDealOffline(t *testing.T) {
assert.True(t, pd.ProposalCid.Equals(proposalCid))
assert.Equal(t, pd.State, storagemarket.StorageDealWaitingForData)

carBuf := new(bytes.Buffer)

err = cario.NewCarIO().WriteCar(ctx, td.Bs1, payloadCid, td.AllSelector, carBuf)
require.NoError(t, err)
err = provider.ImportDataForDeal(ctx, pd.ProposalCid, carBuf)
Expand Down
4 changes: 2 additions & 2 deletions storagemarket/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ type DataRef struct {
TransferType string
Root cid.Cid

PieceCid *cid.Cid // Optional, will be recomputed from the data if not given
PieceSize abi.UnpaddedPieceSize
PieceCid *cid.Cid // Optional for non-manual transfer, will be recomputed from the data if not given
PieceSize abi.UnpaddedPieceSize // Optional for non-manual transfer, will be recomputed from the data if not given
}

// The interface provided by the module to the outside world for storage clients.
Expand Down

0 comments on commit 412b34d

Please sign in to comment.