Skip to content

Commit

Permalink
sealing: ComputeDataCid review
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Apr 27, 2022
1 parent a2d9062 commit 1815108
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 1 addition & 9 deletions extern/sector-storage/ffiwrapper/sealer_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ func (sb *Sealer) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize,

maxSizeSpt := abi.RegisteredSealProof_StackedDrg64GiBV1_1

var done func()

defer func() {
if done != nil {
done()
}
}()

throttle := make(chan []byte, parallel)
piecePromises := make([]func() (abi.PieceInfo, error), 0)

Expand Down Expand Up @@ -123,7 +115,7 @@ func (sb *Sealer) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize,
}

return abi.PieceInfo{
Size: abi.UnpaddedPieceSize(len(buf[:read])).Padded(),
Size: abi.UnpaddedPieceSize(read).Padded(),
PieceCID: e.Cid,
}, nil
case <-ctx.Done():
Expand Down
6 changes: 6 additions & 0 deletions itests/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func TestWorkerDataCid(t *testing.T) {
require.NoError(t, err)
require.Equal(t, abi.PaddedPieceSize(1024), pi.Size)
require.Equal(t, "baga6ea4seaqlhznlutptgfwhffupyer6txswamerq5fc2jlwf2lys2mm5jtiaeq", pi.PieceCID.String())

bigPiece := abi.PaddedPieceSize(16 << 20).Unpadded()
pi, err = miner.ComputeDataCid(ctx, bigPiece, strings.NewReader(strings.Repeat("a", int(bigPiece))))
require.NoError(t, err)
require.Equal(t, bigPiece.Padded(), pi.Size)
require.Equal(t, "baga6ea4seaqlhznlutptgfwhffupyer6txswamerq5fc2jlwf2lys2mm5jtiaeq", pi.PieceCID.String())
}

func TestWinningPostWorker(t *testing.T) {
Expand Down

0 comments on commit 1815108

Please sign in to comment.