Skip to content

Commit

Permalink
Merge pull request #5851 from filecoin-project/fix/rtrvl-log
Browse files Browse the repository at this point in the history
better logging when unsealing fails
  • Loading branch information
magik6k authored Mar 22, 2021
2 parents 43d9cc3 + 14ede9b commit 897c5c7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions markets/retrievaladapter/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"io"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/types"
Expand All @@ -16,10 +19,10 @@ import (
"github.com/filecoin-project/go-fil-markets/shared"
"github.com/filecoin-project/go-state-types/abi"
specstorage "github.com/filecoin-project/specs-storage/storage"

"github.com/ipfs/go-cid"
)

var log = logging.Logger("retrievaladapter")

type retrievalProviderNode struct {
miner *storage.Miner
sealer sectorstorage.SectorManager
Expand Down Expand Up @@ -61,13 +64,20 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi
ProofType: si.SectorType,
}

// Set up a pipe so that data can be written from the unsealing process
// into the reader returned by this function
r, w := io.Pipe()
go func() {
var commD cid.Cid
if si.CommD != nil {
commD = *si.CommD
}
// Read the piece into the pipe's writer, unsealing the piece if necessary
err := rpn.sealer.ReadPiece(ctx, w, ref, storiface.UnpaddedByteIndex(offset), length, si.TicketValue, commD)
if err != nil {
log.Errorf("failed to unseal piece from sector %d: %s", sectorID, err)
}
// Close the reader with any error that was returned while reading the piece
_ = w.CloseWithError(err)
}()

Expand Down

0 comments on commit 897c5c7

Please sign in to comment.