tendermint/example/golang/dummy.go

46 lines
1.0 KiB
Go
Raw Normal View History

2015-11-27 15:42:00 -08:00
package example
2015-11-02 07:39:53 -08:00
import (
. "github.com/tendermint/go-common"
"github.com/tendermint/go-merkle"
"github.com/tendermint/tmsp/types"
)
type DummyApplication struct {
state merkle.Tree
2015-11-02 07:39:53 -08:00
}
func NewDummyApplication() *DummyApplication {
state := merkle.NewIAVLTree(
0,
nil,
)
return &DummyApplication{state: state}
}
func (app *DummyApplication) Info() string {
return Fmt("size:%v", app.state.Size())
}
func (app *DummyApplication) SetOption(key string, value string) (log string) {
return ""
2015-11-02 07:39:53 -08:00
}
func (app *DummyApplication) AppendTx(tx []byte) (code types.RetCode, result []byte, log string) {
app.state.Set(tx, tx)
return types.RetCodeOK, nil, ""
2015-11-02 07:39:53 -08:00
}
func (app *DummyApplication) CheckTx(tx []byte) (code types.RetCode, result []byte, log string) {
return types.RetCodeOK, nil, ""
2015-11-02 07:39:53 -08:00
}
func (app *DummyApplication) GetHash() (hash []byte, log string) {
hash = app.state.Hash()
return hash, ""
2016-01-18 14:37:42 -08:00
}
2016-01-31 18:11:24 -08:00
func (app *DummyApplication) Query(query []byte) (code types.RetCode, result []byte, log string) {
return types.RetCodeOK, nil, "Query not supported"
2015-11-02 07:39:53 -08:00
}