mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-31 20:36:13 +00:00
Fix up commits, debug cli tests
This commit is contained in:
+16
-1
@@ -1,6 +1,7 @@
|
||||
package dummy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/abci/types"
|
||||
@@ -33,6 +34,7 @@ func (app *DummyApplication) DeliverTx(tx []byte) types.Result {
|
||||
} else {
|
||||
app.state.Set(tx, tx)
|
||||
}
|
||||
fmt.Println("set data")
|
||||
return types.OK
|
||||
}
|
||||
|
||||
@@ -41,7 +43,20 @@ func (app *DummyApplication) CheckTx(tx []byte) types.Result {
|
||||
}
|
||||
|
||||
func (app *DummyApplication) Commit() types.Result {
|
||||
hash := app.state.Hash()
|
||||
// Save a new version
|
||||
var hash []byte
|
||||
var err error
|
||||
|
||||
if app.state.Size() > 0 {
|
||||
// just add one more to height (kind of arbitrarily stupid)
|
||||
height := app.state.LatestVersion() + 1
|
||||
hash, err = app.state.SaveVersion(height)
|
||||
if err != nil {
|
||||
// if this wasn't a dummy app, we'd do something smarter
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
return types.NewResultOK(hash, "")
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
|
||||
// Save a new version
|
||||
var appHash []byte
|
||||
var err error
|
||||
|
||||
if app.app.state.Size() > 0 {
|
||||
appHash, err = app.app.state.SaveVersion(app.height)
|
||||
if err != nil {
|
||||
@@ -103,12 +104,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
|
||||
app.logger.Info("Saved state", "root", appHash)
|
||||
}
|
||||
|
||||
lastBlock := LastBlockInfo{
|
||||
Height: app.height,
|
||||
AppHash: appHash, // this hash will be in the next block header
|
||||
}
|
||||
|
||||
app.logger.Info("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
|
||||
app.logger.Info("Commit block", "height", app.height, "root", appHash)
|
||||
return types.NewResultOK(appHash, "")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user