-
Notifications
You must be signed in to change notification settings - Fork 42
Return error if any in mempool CheckTx and fix callback
#311
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
758743c
e139fc9
7ae635d
d231364
0b921c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,6 +363,7 @@ func (txmp *TxMempool) CheckTx( | |
| if err != nil { | ||
| removeHandler(true) | ||
| res.Log = txmp.AppendCheckTxErr(res.Log, err.Error()) | ||
| return err | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would break the existing broadcast logic if we return err instead of putting err in the response. Currently error is already being handled by adding to the res.log and passed into cb function back to the client
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After a second though, I think it makes more sense to return error to the client rather than putting error in the response log, so the change LGTM. Probably need to evaluate whether there's any risk/impact to the existing client or not. |
||
| } | ||
|
|
||
| wtx := &WrappedTx{ | ||
|
|
@@ -377,28 +378,26 @@ func (txmp *TxMempool) CheckTx( | |
| estimatedGas: res.GasEstimated, | ||
| } | ||
|
|
||
| if err == nil { | ||
| // only add new transaction if checkTx passes and is not pending | ||
| if !res.IsPendingTransaction { | ||
| err = txmp.addNewTransaction(wtx, res.ResponseCheckTx, txInfo) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } else { | ||
| // otherwise add to pending txs store | ||
| if res.Checker == nil { | ||
| return errors.New("no checker available for pending transaction") | ||
| } | ||
| if err := txmp.canAddPendingTx(wtx); err != nil { | ||
| // TODO: eviction strategy for pending transactions | ||
| removeHandler(true) | ||
| return err | ||
| } | ||
| atomic.AddInt64(&txmp.pendingSizeBytes, int64(wtx.Size())) | ||
| if err := txmp.pendingTxs.Insert(wtx, res, txInfo); err != nil { | ||
| return err | ||
| } | ||
| // only add new transaction if checkTx passes and is not pending | ||
| if !res.IsPendingTransaction { | ||
| err = txmp.addNewTransaction(wtx, res.ResponseCheckTx, txInfo) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } else { | ||
| // otherwise add to pending txs store | ||
| if res.Checker == nil { | ||
| return errors.New("no checker available for pending transaction") | ||
| } | ||
| if err := txmp.canAddPendingTx(wtx); err != nil { | ||
| // TODO: eviction strategy for pending transactions | ||
| removeHandler(true) | ||
| return err | ||
| } | ||
| if err := txmp.pendingTxs.Insert(wtx, res, txInfo); err != nil { | ||
| return err | ||
| } | ||
| atomic.AddInt64(&txmp.pendingSizeBytes, int64(wtx.Size())) | ||
| } | ||
|
|
||
| if cb != nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.