diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index 816a025e9..400b67211 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -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) @@ -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(): diff --git a/itests/worker_test.go b/itests/worker_test.go index 59d1407fd..12fc96417 100644 --- a/itests/worker_test.go +++ b/itests/worker_test.go @@ -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, "baga6ea4seaqmhoxl2ybw5m2wyd3pt3h4zmp7j52yumzu2rar26twns3uocq7yfa", pi.PieceCID.String()) } func TestWinningPostWorker(t *testing.T) {