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

allow manual piece commitment #135

Merged
merged 1 commit into from
Mar 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion storagemarket/impl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ type ClientDealProposal struct {
}

func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, error) {
commP, pieceSize, err := c.commP(ctx, p.ProofType, p.Data.Root)
commP, pieceSize, err := c.commP(ctx, p.ProofType, p.Data)
if err != nil {
return cid.Undef, xerrors.Errorf("computing commP failed: %w", err)
}
Expand Down
9 changes: 7 additions & 2 deletions storagemarket/impl/client_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/filecoin-project/go-address"
cborutil "github.com/filecoin-project/go-cbor-util"
datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-fil-markets/storagemarket/network"
"github.com/filecoin-project/go-statestore"
)
Expand All @@ -38,14 +39,18 @@ func (c *Client) failDeal(id cid.Cid, cerr error) {
log.Errorf("deal %s failed: %+v", id, cerr)
}

func (c *Client) commP(ctx context.Context, rt abi.RegisteredProof, root cid.Cid) (cid.Cid, abi.UnpaddedPieceSize, error) {
func (c *Client) commP(ctx context.Context, rt abi.RegisteredProof, data *storagemarket.DataRef) (cid.Cid, abi.UnpaddedPieceSize, error) {
if data.PieceCid != nil {
return *data.PieceCid, data.PieceSize, nil
}

ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())

// entire DAG selector
allSelector := ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()

commp, paddedSize, err := c.pio.GeneratePieceCommitment(rt, root, allSelector)
commp, paddedSize, err := c.pio.GeneratePieceCommitment(rt, data.Root, allSelector)
if err != nil {
return cid.Undef, 0, xerrors.Errorf("generating CommP: %w", err)
}
Expand Down
3 changes: 3 additions & 0 deletions storagemarket/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ const (
type DataRef struct {
TransferType string
Root cid.Cid

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

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