Skip to content

Commit

Permalink
Merge PR #4876: Fix BroadcastTxCommit Response
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Aug 13, 2019
1 parent cacd759 commit 12557e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .pending/bugfixes/rest/_4858-Do-not-return-
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 4 additions & 3 deletions client/context/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 12557e9

Please sign in to comment.