From 73d5225f3c7e332eb3fefb94911ab567af243372 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Mon, 22 Mar 2021 10:23:58 +0100 Subject: [PATCH] fix: better logging when unsealing fails --- markets/retrievaladapter/provider.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/markets/retrievaladapter/provider.go b/markets/retrievaladapter/provider.go index 440e2a480..cd77d9fd0 100644 --- a/markets/retrievaladapter/provider.go +++ b/markets/retrievaladapter/provider.go @@ -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" @@ -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 @@ -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 } + // Unseal the piece into the pipe's writer 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) }()