client: remove redundant/repeated code (#8182)
Follows up PR #4876 which removed the return on non-nil errors to always return a non-nil REST response regardless of error. The checks performed seem benign and the return result is the same. This change uses the reverse conditional refactoring method to gut out nesting and many conditions. Noticed while hunting through types.ParseABCILogs. Fixes #8181
This commit is contained in:
parent
002da6183c
commit
96f89df56b
|
@ -95,23 +95,14 @@ func (ctx Context) BroadcastTxCommit(txBytes []byte) (*sdk.TxResponse, error) {
|
|||
}
|
||||
|
||||
res, err := node.BroadcastTxCommit(context.Background(), txBytes)
|
||||
if err != nil {
|
||||
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
|
||||
return errRes, nil
|
||||
}
|
||||
|
||||
return sdk.NewResponseFormatBroadcastTxCommit(res), err
|
||||
}
|
||||
|
||||
if !res.CheckTx.IsOK() {
|
||||
if err == nil {
|
||||
return sdk.NewResponseFormatBroadcastTxCommit(res), nil
|
||||
}
|
||||
|
||||
if !res.DeliverTx.IsOK() {
|
||||
return sdk.NewResponseFormatBroadcastTxCommit(res), nil
|
||||
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
|
||||
return errRes, nil
|
||||
}
|
||||
|
||||
return sdk.NewResponseFormatBroadcastTxCommit(res), nil
|
||||
return sdk.NewResponseFormatBroadcastTxCommit(res), err
|
||||
}
|
||||
|
||||
// BroadcastTxSync broadcasts transaction bytes to a Tendermint node
|
||||
|
|
Loading…
Reference in New Issue