Skip to content

Commit

Permalink
(fixup) Revert the CheckTxSync callback parameter from https://github…
Browse files Browse the repository at this point in the history
  • Loading branch information
tnasu committed Jul 13, 2023
1 parent 1552e91 commit 36637c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions consensus/replay_stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var _ mempl.Mempool = emptyMempool{}
func (emptyMempool) Lock() {}
func (emptyMempool) Unlock() {}
func (emptyMempool) Size() int { return 0 }
func (emptyMempool) CheckTxSync(_ types.Tx, _ mempl.TxInfo) (*ocabci.Response, error) {
return nil, nil
func (emptyMempool) CheckTxSync(_ types.Tx, _ func(*ocabci.Response), _ mempl.TxInfo) error {
return nil
}
func (emptyMempool) CheckTxAsync(_ types.Tx, _ mempl.TxInfo, _ func(error), _ func(*ocabci.Response)) {
}
Expand Down
16 changes: 8 additions & 8 deletions mempool/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,25 @@ func (mem *CListMempool) TxsWaitChan() <-chan struct{} {

// It blocks if we're waiting on Update() or Reap().
// Safe for concurrent use by multiple goroutines.
func (mem *CListMempool) CheckTxSync(tx types.Tx, txInfo TxInfo) (res *ocabci.Response, err error) {
func (mem *CListMempool) CheckTxSync(tx types.Tx, cb func(*ocabci.Response), txInfo TxInfo) error {
mem.updateMtx.RLock()
// use defer to unlock mutex because application (*local client*) might panic
defer mem.updateMtx.RUnlock()

if err = mem.prepareCheckTx(tx, txInfo); err != nil {
return res, err
if err := mem.prepareCheckTx(tx, txInfo); err != nil {
return err
}

// CONTRACT: `app.CheckTxSync()` should check whether `GasWanted` is valid (0 <= GasWanted <= block.masGas)
var r *ocabci.ResponseCheckTx
r, err = mem.proxyAppConn.CheckTxSync(abci.RequestCheckTx{Tx: tx})
r, err := mem.proxyAppConn.CheckTxSync(abci.RequestCheckTx{Tx: tx})
if err != nil {
return res, err
return err
}

res = ocabci.ToResponseCheckTx(*r)
mem.reqResCb(tx, txInfo.SenderID, txInfo.SenderP2PID, res, nil)
return res, err
res := ocabci.ToResponseCheckTx(*r)
mem.reqResCb(tx, txInfo.SenderID, txInfo.SenderP2PID, res, cb)
return err
}

// cb: A callback from the CheckTx command.
Expand Down
2 changes: 1 addition & 1 deletion mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type Mempool interface {
// CheckTx executes a new transaction against the application to determine
// its validity and whether it should be added to the mempool.
CheckTxSync(tx types.Tx, txInfo TxInfo) (*ocabci.Response, error)
CheckTxSync(tx types.Tx, checkTxCb func(*ocabci.Response), txInfo TxInfo) error
CheckTxAsync(tx types.Tx, txInfo TxInfo, prepareCb func(error), checkTxCb func(*ocabci.Response))

// ReapMaxBytesMaxGas reaps transactions from the mempool up to maxBytes
Expand Down

0 comments on commit 36637c0

Please sign in to comment.