From 28cf6fcf52f99d40e714bf07d70a73a7fcb68b5e Mon Sep 17 00:00:00 2001 From: William Banfield Date: Thu, 6 Jan 2022 18:33:43 -0500 Subject: [PATCH] remove superfluous 0 check and add bytes to import --- docs/tutorials/go-built-in.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/go-built-in.md b/docs/tutorials/go-built-in.md index f7b747242..001a33202 100644 --- a/docs/tutorials/go-built-in.md +++ b/docs/tutorials/go-built-in.md @@ -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.