@@ -45,7 +45,6 @@ import (
45
45
46
46
"github.com/filecoin-project/go-address"
47
47
cborutil "github.com/filecoin-project/go-cbor-util"
48
- "github.com/filecoin-project/go-commp-utils/ffiwrapper"
49
48
"github.com/filecoin-project/go-commp-utils/writer"
50
49
datatransfer "github.com/filecoin-project/go-data-transfer/v2"
51
50
"github.com/filecoin-project/go-fil-markets/discovery"
@@ -1332,47 +1331,7 @@ func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Addre
1332
1331
}
1333
1332
1334
1333
func (a * API ) ClientCalcCommP (ctx context.Context , inpath string ) (* types.CommPRet , error ) {
1335
- // Hard-code the sector type to 32GiBV1_1, because:
1336
- // - ffiwrapper.GeneratePieceCIDFromFile requires a RegisteredSealProof
1337
- // - commP itself is sector-size independent, with rather low probability of that changing
1338
- // ( note how the final rust call is identical for every RegSP type )
1339
- // https://github.com/filecoin-project/rust-filecoin-proofs-api/blob/v5.0.0/src/seal.rs#L1040-L1050
1340
- //
1341
- // IF/WHEN this changes in the future we will have to be able to calculate
1342
- // "old style" commP, and thus will need to introduce a version switch or similar
1343
- arbitraryProofType := abi .RegisteredSealProof_StackedDrg32GiBV1_1
1344
-
1345
- rdr , err := os .Open (inpath )
1346
- if err != nil {
1347
- return nil , err
1348
- }
1349
- defer rdr .Close () //nolint:errcheck
1350
-
1351
- stat , err := rdr .Stat ()
1352
- if err != nil {
1353
- return nil , err
1354
- }
1355
-
1356
- // check that the data is a car file; if it's not, retrieval won't work
1357
- _ , err = car .ReadHeader (bufio .NewReader (rdr ))
1358
- if err != nil {
1359
- return nil , fmt .Errorf ("not a car file: %w" , err )
1360
- }
1361
-
1362
- if _ , err := rdr .Seek (0 , io .SeekStart ); err != nil {
1363
- return nil , fmt .Errorf ("seek to start: %w" , err )
1364
- }
1365
-
1366
- pieceReader , pieceSize := padreader .New (rdr , uint64 (stat .Size ()))
1367
- commP , err := ffiwrapper .GeneratePieceCIDFromFile (arbitraryProofType , pieceReader , pieceSize )
1368
- if err != nil {
1369
- return nil , fmt .Errorf ("computing commP failed: %w" , err )
1370
- }
1371
-
1372
- return & types.CommPRet {
1373
- Root : commP ,
1374
- Size : pieceSize ,
1375
- }, nil
1334
+ return utils .CalcCommP (ctx , inpath )
1376
1335
}
1377
1336
1378
1337
type lenWriter int64
0 commit comments