Skip to content

Commit

Permalink
vochain: check if sendTx result is nil before printing it
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <[email protected]>
  • Loading branch information
p4u committed Feb 16, 2024
1 parent 43e01c5 commit 85b22b0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions vochain/appsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ func (app *BaseApplication) SetDefaultMethods() {
app.SetFnMempoolPrune(app.fnMempoolRemoveTxTendermint)
app.SetFnSendTx(func(tx []byte) (*cometcoretypes.ResultBroadcastTx, error) {
result, err := app.NodeClient.BroadcastTxSync(context.Background(), tx)
if result.Code != 0 && err == nil {
errmsg := string(result.Data)
err = fmt.Errorf("%s", errmsg)
if err != nil {
return nil, err
}
log.Debugw("broadcast tx",
"size", len(tx),
Expand All @@ -75,16 +74,19 @@ func (app *BaseApplication) SetDefaultMethods() {
}
return int(result.Code)
}(),
"error",
func() string {
if err == nil {
return ""
}
return err.Error()
}(),
"data", result.Data,
)
if result == nil {
return nil, fmt.Errorf("no result returned from broadcast tx")
}
if result.Code != 0 {
errmsg := string(result.Data)
err = fmt.Errorf("%s", errmsg)
return result, err
}
return result, err
})

}

func (app *BaseApplication) getTxTendermint(height uint32, txIndex int32) (*models.SignedTx, error) {
Expand Down

0 comments on commit 85b22b0

Please sign in to comment.