Merge PR #4876: Fix BroadcastTxCommit Response

This commit is contained in:
Alexander Bezobchuk 2019-08-13 09:21:52 -04:00 committed by GitHub
parent 46c98d396d
commit fee71e72d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -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.

View File

@ -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