mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-03 22:51:37 +00:00
Cleaup based on Antons PR comments
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
package dummy
|
package dummy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
@ -34,7 +33,6 @@ func (app *DummyApplication) DeliverTx(tx []byte) types.Result {
|
|||||||
} else {
|
} else {
|
||||||
app.state.Set(tx, tx)
|
app.state.Set(tx, tx)
|
||||||
}
|
}
|
||||||
fmt.Println("set data")
|
|
||||||
return types.OK
|
return types.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +61,7 @@ func (app *DummyApplication) Commit() types.Result {
|
|||||||
func (app *DummyApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {
|
func (app *DummyApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {
|
||||||
if reqQuery.Prove {
|
if reqQuery.Prove {
|
||||||
value, proof, err := app.state.GetWithProof(reqQuery.Data)
|
value, proof, err := app.state.GetWithProof(reqQuery.Data)
|
||||||
// be stupid here
|
// if this wasn't a dummy app, we'd do something smarter
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -71,7 +69,7 @@ func (app *DummyApplication) Query(reqQuery types.RequestQuery) (resQuery types.
|
|||||||
resQuery.Key = reqQuery.Data
|
resQuery.Key = reqQuery.Data
|
||||||
resQuery.Value = value
|
resQuery.Value = value
|
||||||
resQuery.Proof = wire.BinaryBytes(proof)
|
resQuery.Proof = wire.BinaryBytes(proof)
|
||||||
if value == nil {
|
if value != nil {
|
||||||
resQuery.Log = "exists"
|
resQuery.Log = "exists"
|
||||||
} else {
|
} else {
|
||||||
resQuery.Log = "does not exist"
|
resQuery.Log = "does not exist"
|
||||||
|
@ -89,14 +89,14 @@ func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *PersistentDummyApplication) Commit() types.Result {
|
func (app *PersistentDummyApplication) Commit() types.Result {
|
||||||
app.height = app.blockHeader.Height
|
h := app.blockHeader.Height
|
||||||
|
|
||||||
// Save a new version
|
// Save a new version
|
||||||
var appHash []byte
|
var appHash []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if app.app.state.Size() > 0 {
|
if app.app.state.Size() > 0 {
|
||||||
appHash, err = app.app.state.SaveVersion(app.height)
|
appHash, err = app.app.state.SaveVersion(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// if this wasn't a dummy app, we'd do something smarter
|
// if this wasn't a dummy app, we'd do something smarter
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -104,7 +104,8 @@ func (app *PersistentDummyApplication) Commit() types.Result {
|
|||||||
app.logger.Info("Saved state", "root", appHash)
|
app.logger.Info("Saved state", "root", appHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.logger.Info("Commit block", "height", app.height, "root", appHash)
|
app.height = h
|
||||||
|
app.logger.Info("Commit block", "height", h, "root", appHash)
|
||||||
return types.NewResultOK(appHash, "")
|
return types.NewResultOK(appHash, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ function testExample() {
|
|||||||
|
|
||||||
echo "Example $N"
|
echo "Example $N"
|
||||||
$APP &> /dev/null &
|
$APP &> /dev/null &
|
||||||
# $APP &> ./app.out &
|
|
||||||
sleep 2
|
sleep 2
|
||||||
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
|
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
|
||||||
killall "$APP"
|
killall "$APP"
|
||||||
|
Reference in New Issue
Block a user