From 0beb48f11d863e82dba4ccdd63834001ccfb4f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 19 Aug 2021 12:56:40 +0200 Subject: [PATCH] Fix error handling in SectorAddPieceToAny api impl --- node/impl/storminer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 5f0826b0e02..657e8cfdf3c 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -212,7 +212,13 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumb } func (sm *StorageMinerAPI) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPieceSize, r sto.Data, d api.PieceDealInfo) (api.SectorOffset, error) { - return sm.Miner.SectorAddPieceToAny(ctx, size, r, d) + so, err := sm.Miner.SectorAddPieceToAny(ctx, size, r, d) + if err != nil { + // jsonrpc doesn't support returning values with errors, make sure we never do that + return api.SectorOffset{}, err + } + + return so, nil } func (sm *StorageMinerAPI) SectorsUnsealPiece(ctx context.Context, sector sto.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, commd *cid.Cid) error {