Skip to content

Commit

Permalink
wire through proper piece size
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Apr 7, 2021
1 parent 314babd commit 65658e3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions storagemarket/impl/providerstates/provider_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func HandoffDeal(ctx fsm.Context, environment ProviderDealEnvironment, deal stor
}

// Hand the deal off to the process that adds it to a sector
packingInfo, err = handoffDeal(ctx.Context(), environment, deal, file, uint64(file.Size()))
packingInfo, err = handoffDeal(ctx.Context(), environment, deal, file, uint64(file.Size()), deal.Proposal.PieceSize)
if err != nil {
err = xerrors.Errorf("packing piece at path %s: %w", deal.PiecePath, err)
return ctx.Trigger(storagemarket.ProviderEventDealHandoffFailed, err)
Expand All @@ -324,7 +324,7 @@ func HandoffDeal(ctx fsm.Context, environment ProviderDealEnvironment, deal stor

// Hand the deal off to the process that adds it to a sector
var packingErr error
packingInfo, packingErr = handoffDeal(ctx.Context(), environment, deal, pieceReader, pieceSize)
packingInfo, packingErr = handoffDeal(ctx.Context(), environment, deal, pieceReader, pieceSize, deal.Proposal.PieceSize)

// Close the read side of the pipe
err = pieceReader.Close()
Expand Down Expand Up @@ -360,8 +360,8 @@ func HandoffDeal(ctx fsm.Context, environment ProviderDealEnvironment, deal stor
return ctx.Trigger(storagemarket.ProviderEventDealHandedOff)
}

func handoffDeal(ctx context.Context, environment ProviderDealEnvironment, deal storagemarket.MinerDeal, reader io.Reader, size uint64) (*storagemarket.PackingResult, error) {
paddedReader, paddedSize := padreader.New(reader, size)
func handoffDeal(ctx context.Context, environment ProviderDealEnvironment, deal storagemarket.MinerDeal, reader io.Reader, payloadSize uint64, pieceSize abi.PaddedPieceSize) (*storagemarket.PackingResult, error) {
paddedReader, _ := padreader.New(reader, payloadSize)
return environment.Node().OnDealComplete(
ctx,
storagemarket.MinerDeal{
Expand All @@ -374,7 +374,7 @@ func handoffDeal(ctx context.Context, environment ProviderDealEnvironment, deal
DealID: deal.DealID,
FastRetrieval: deal.FastRetrieval,
},
paddedSize,
pieceSize.Unpadded(),
paddedReader,
)
}
Expand Down

0 comments on commit 65658e3

Please sign in to comment.