From fee71e72d4f1aba136a32232a5546f68e9ceb41b Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Tue, 13 Aug 2019 09:21:52 -0400 Subject: [PATCH] Merge PR #4876: Fix BroadcastTxCommit Response --- .pending/bugfixes/rest/_4858-Do-not-return- | 3 +++ client/context/broadcast.go | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .pending/bugfixes/rest/_4858-Do-not-return- diff --git a/.pending/bugfixes/rest/_4858-Do-not-return- b/.pending/bugfixes/rest/_4858-Do-not-return- new file mode 100644 index 0000000000..5459f75105 --- /dev/null +++ b/.pending/bugfixes/rest/_4858-Do-not-return- @@ -0,0 +1,3 @@ +#4858 Do not return an error in BroadcastTxCommit when the tx broadcasting +was successful. This allows the proper REST response to be returned for a +failed tx during `block` broadcasting mode. diff --git a/client/context/broadcast.go b/client/context/broadcast.go index 8aa770ce19..9c1a720ae7 100644 --- a/client/context/broadcast.go +++ b/client/context/broadcast.go @@ -30,7 +30,8 @@ func (ctx CLIContext) BroadcastTx(txBytes []byte) (res sdk.TxResponse, err error } // BroadcastTxCommit broadcasts transaction bytes to a Tendermint node and -// waits for a commit. +// waits for a commit. An error is only returned if there is no RPC node +// connection or if broadcasting fails. // // NOTE: This should ideally not be used as the request may timeout but the tx // may still be included in a block. Use BroadcastTxAsync or BroadcastTxSync @@ -47,11 +48,11 @@ func (ctx CLIContext) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error) } if !res.CheckTx.IsOK() { - return sdk.NewResponseFormatBroadcastTxCommit(res), fmt.Errorf(res.CheckTx.Log) + return sdk.NewResponseFormatBroadcastTxCommit(res), nil } if !res.DeliverTx.IsOK() { - return sdk.NewResponseFormatBroadcastTxCommit(res), fmt.Errorf(res.DeliverTx.Log) + return sdk.NewResponseFormatBroadcastTxCommit(res), nil } return sdk.NewResponseFormatBroadcastTxCommit(res), nil