Skip to content

Commit

Permalink
Revert "fix: error handling after check tx (#178)" (#180)
Browse files Browse the repository at this point in the history
This reverts commit bc952ea
  • Loading branch information
wetcod authored Feb 4, 2021
1 parent bc952ea commit 629ddc8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
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

0 comments on commit 629ddc8

Please sign in to comment.