From df069af5e5126c8d6b14681e9919fe70fc86b4b9 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 4 Dec 2019 21:02:14 -0800 Subject: [PATCH] some errcheck discoveries --- cli/state.go | 14 +++++++++++++- node/modules/client.go | 4 +++- node/modules/storageminer.go | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cli/state.go b/cli/state.go index 24809f982..5b25e1db4 100644 --- a/cli/state.go +++ b/cli/state.go @@ -5,6 +5,7 @@ import ( "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/types" + "golang.org/x/xerrors" "github.com/ipfs/go-cid" "gopkg.in/urfave/cli.v2" @@ -176,7 +177,18 @@ var stateReplaySetCmd = &cli.Command{ return err } - api.StateReplay(ctx, ts, mcid) + res, err := api.StateReplay(ctx, ts, mcid) + if err != nil { + return xerrors.Errorf("replay call failed: %w", err) + } + + fmt.Println("Replay receipt:") + fmt.Printf("Exit code: %d\n", res.Receipt.ExitCode) + fmt.Printf("Return: %x\n", res.Receipt.Return) + fmt.Printf("Gas Used: %s\n", res.Receipt.GasUsed) + if res.Receipt.ExitCode != 0 { + fmt.Printf("Error message: %q\n", res.Error) + } return nil }, diff --git a/node/modules/client.go b/node/modules/client.go index 5a0832c32..76cb77263 100644 --- a/node/modules/client.go +++ b/node/modules/client.go @@ -49,7 +49,9 @@ func ClientBlockstore(fstore dtypes.ClientFilestore) dtypes.ClientBlockstore { // request validator with the data transfer module as the validator for // StorageDataTransferVoucher types func RegisterClientValidator(crv *deals.ClientRequestValidator, dtm dtypes.ClientDataTransfer) { - dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), crv) + if err := dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), crv); err != nil { + panic(err) + } } // NewClientDAGServiceDataTransfer returns a data transfer manager that just diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index eaa2a837a..73bf29c06 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -139,7 +139,9 @@ func HandleDeals(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, h *de // request validator with the data transfer module as the validator for // StorageDataTransferVoucher types func RegisterProviderValidator(mrv *deals.ProviderRequestValidator, dtm dtypes.ProviderDataTransfer) { - dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), mrv) + if err := dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), mrv); err != nil { + panic(err) + } } // NewProviderDAGServiceDataTransfer returns a data transfer manager that just