Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: error handling after check tx" #180

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions mempool/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,7 @@ func (mem *CListMempool) reqResCb(
panic("recheck cursor is not nil in reqResCb")
}

err := mem.resCbFirstTime(tx, peerID, peerP2PID, res)
if err != nil {
if externalCb != nil {
externalCb(abci.ToResponseException(err.Error()))
}
return
}
mem.resCbFirstTime(tx, peerID, peerP2PID, res)

// update metrics
mem.metrics.Size.Set(float64(mem.Size()))
Expand Down Expand Up @@ -400,11 +394,11 @@ func (mem *CListMempool) resCbFirstTime(
peerID uint16,
peerP2PID p2p.ID,
res *abci.Response,
) error {
) {
switch r := res.Value.(type) {
case *abci.Response_CheckTx:
var postCheckErr error
if (r.CheckTx.Code == abci.CodeTypeOK) && mem.postCheck != nil {
if mem.postCheck != nil {
postCheckErr = mem.postCheck(tx, r.CheckTx)
}
if (r.CheckTx.Code == abci.CodeTypeOK) && postCheckErr == nil {
Expand All @@ -414,7 +408,7 @@ func (mem *CListMempool) resCbFirstTime(
// remove from cache (mempool might have a space later)
mem.cache.Remove(tx)
mem.logger.Error(err.Error())
return err
return
}

memTx := &mempoolTx{
Expand All @@ -438,13 +432,10 @@ func (mem *CListMempool) resCbFirstTime(
mem.metrics.FailedTxs.Add(1)
// remove from cache (it might be good later)
mem.cache.Remove(tx)
return postCheckErr
}
default:
// ignore other messages
}

return nil
}

// callback, which is called after the app rechecked the tx.
Expand Down
9 changes: 0 additions & 9 deletions rpc/core/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcas
return nil, err
}
res := <-resCh
except := res.GetException()
if except != nil {
return nil, fmt.Errorf(except.Error)
}
r := res.GetCheckTx()
return &ctypes.ResultBroadcastTx{
Code: r.Code,
Expand Down Expand Up @@ -88,11 +84,6 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc
return nil, fmt.Errorf("error on broadcastTxCommit: %v", err)
}
checkTxResMsg := <-checkTxResCh
checkTxExcept := checkTxResMsg.GetException()
if checkTxExcept != nil {
env.Logger.Error("Error on broadcastTxCommit", "err", checkTxExcept.Error)
return nil, fmt.Errorf("error on broadcastTxCommit: %v", checkTxExcept.Error)
}
checkTxRes := checkTxResMsg.GetCheckTx()
if checkTxRes.Code != abci.CodeTypeOK {
return &ctypes.ResultBroadcastTxCommit{
Expand Down