Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve offline deals #183

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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