Skip to content

Commit 4802f63

Browse files
authored
Merge pull request #130 from neelvirdy/nvirdy/option-for-remove-unsealed-2
Expose option to set removeUnsealed when calling MakeDeal
2 parents b5d2e38 + e5c7f84 commit 4802f63

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

filc/cmds.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ var makeDealCmd = &cli.Command{
124124
}
125125

126126
verified := parseVerified(cctx)
127+
removeUnsealed := parseRemoveUnsealed(cctx)
127128

128129
price := ask.Ask.Ask.Price
129130
if verified {
@@ -134,7 +135,7 @@ var makeDealCmd = &cli.Command{
134135
}
135136

136137
minPieceSize := ask.Ask.Ask.MinPieceSize
137-
proposal, err := fc.MakeDeal(cctx.Context, miner, obj.Cid(), price, minPieceSize, 2880*365, verified)
138+
proposal, err := fc.MakeDeal(cctx.Context, miner, obj.Cid(), price, minPieceSize, 2880*365, verified, removeUnsealed)
138139
if err != nil {
139140
return err
140141
}

filc/flags.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package main
22

3-
import cli "github.com/urfave/cli/v2"
3+
import "github.com/urfave/cli/v2"
44

55
var flagMiner = &cli.StringFlag{
66
Name: "miner",
@@ -28,6 +28,10 @@ var flagVerified = &cli.BoolFlag{
2828
Name: "verified",
2929
}
3030

31+
var removeUnsealed = &cli.BoolFlag{
32+
Name: "remove-unsealed",
33+
}
34+
3135
var flagOutput = &cli.StringFlag{
3236
Name: "output",
3337
Aliases: []string{"o"},

filc/parsing.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/filecoin-project/go-address"
99
"github.com/google/uuid"
10-
cli "github.com/urfave/cli/v2"
10+
"github.com/urfave/cli/v2"
1111
)
1212

1313
// Read a single miner from the CLI, returning address.Undef if none is
@@ -53,6 +53,11 @@ func parseVerified(cctx *cli.Context) bool {
5353
return cctx.Bool(flagVerified.Name)
5454
}
5555

56+
// Get whether to ask SP to remove unsealed copy.
57+
func parseRemoveUnsealed(cctx *cli.Context) bool {
58+
return cctx.Bool(removeUnsealed.Name)
59+
}
60+
5661
// Get the destination file to write the output to, erroring if not a valid
5762
// path. This early error check is important because you don't want to do a
5863
// bunch of work, only to end up crashing when you try to write the file.

filclient.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func ComputePrice(askPrice types.BigInt, size abi.PaddedPieceSize, duration abi.
499499
return (*abi.TokenAmount)(&cost), nil
500500
}
501501

502-
func (fc *FilClient) MakeDeal(ctx context.Context, miner address.Address, data cid.Cid, price types.BigInt, minSize abi.PaddedPieceSize, duration abi.ChainEpoch, verified bool) (*network.Proposal, error) {
502+
func (fc *FilClient) MakeDeal(ctx context.Context, miner address.Address, data cid.Cid, price types.BigInt, minSize abi.PaddedPieceSize, duration abi.ChainEpoch, verified bool, removeUnsealed bool) (*network.Proposal, error) {
503503
ctx, span := Tracer.Start(ctx, "makeDeal", trace.WithAttributes(
504504
attribute.Stringer("miner", miner),
505505
attribute.Stringer("price", price),
@@ -587,7 +587,7 @@ func (fc *FilClient) MakeDeal(ctx context.Context, miner address.Address, data c
587587
Root: data,
588588
RawBlockSize: dataSize,
589589
},
590-
FastRetrieval: true,
590+
FastRetrieval: !removeUnsealed,
591591
}, nil
592592
}
593593

filclient_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestStorage(t *testing.T) {
145145
)
146146
require.NoError(t, err)
147147

148-
proposal, err := fc.MakeDeal(ctx, addr, obj.Cid(), ask.Ask.Ask.Price, 0, 2880*365, false)
148+
proposal, err := fc.MakeDeal(ctx, addr, obj.Cid(), ask.Ask.Ask.Price, 0, 2880*365, false, false)
149149
require.NoError(t, err)
150150

151151
fmt.Printf("Sending proposal\n")

0 commit comments

Comments
 (0)