mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-08 21:10:10 +00:00
remove superfluous 0 check and add bytes to import
This commit is contained in:
@@ -210,14 +210,13 @@ func (app *KVStoreApplication) validateTx(tx []byte) uint32 {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
And call it from within your `CheckTx` method:
|
||||
|
||||
```go
|
||||
func (app *KVStoreApplication) CheckTx(req abcitypes.RequestCheckTx) abcitypes.ResponseCheckTx {
|
||||
if code := app.validateTx(req.Tx); code != 0 {
|
||||
return abcitypes.ResponseCheckTx{Code: code}
|
||||
}
|
||||
return abcitypes.ResponseCheckTx{Code: 0}
|
||||
code := app.validateTx(req.Tx)
|
||||
return abcitypes.ResponseCheckTx{Code: code}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -227,6 +226,18 @@ the validation checks. The specific value of the code is meaningless to Tendermi
|
||||
Non-zero codes are logged by Tendermint so applications can provide more specific
|
||||
information on why the transaction was rejected.
|
||||
|
||||
Finally, make sure to add the `bytes` package to the your import stanza
|
||||
at the top of `app.go`:
|
||||
|
||||
```go
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
abcitypes "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
While this `CheckTx` is simple and only validates that the transaction is well-formed,
|
||||
it is very common for `CheckTx` to make more complex use of the state of an application.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user