2015-11-27 18:42:00 -05: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 {
|
2015-11-29 14:22:30 -08:00
|
|
|
state merkle.Tree
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewDummyApplication() *DummyApplication {
|
|
|
|
state := merkle.NewIAVLTree(
|
|
|
|
0,
|
|
|
|
nil,
|
|
|
|
)
|
2015-11-29 14:22:30 -08:00
|
|
|
return &DummyApplication{state: state}
|
|
|
|
}
|
|
|
|
|
2016-01-25 08:01:18 -08:00
|
|
|
func (app *DummyApplication) Info() string {
|
|
|
|
return Fmt("size:%v", app.state.Size())
|
2015-11-09 16:29:45 -08:00
|
|
|
}
|
|
|
|
|
2016-01-25 08:01:18 -08:00
|
|
|
func (app *DummyApplication) SetOption(key string, value string) (log string) {
|
|
|
|
return ""
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-31 20:39:43 -08:00
|
|
|
func (app *DummyApplication) AppendTx(tx []byte) (code types.CodeType, result []byte, log string) {
|
2016-01-08 16:52:02 -08:00
|
|
|
app.state.Set(tx, tx)
|
2016-01-31 20:39:43 -08:00
|
|
|
return types.CodeType_OK, nil, ""
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-31 20:39:43 -08:00
|
|
|
func (app *DummyApplication) CheckTx(tx []byte) (code types.CodeType, result []byte, log string) {
|
|
|
|
return types.CodeType_OK, nil, ""
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-25 08:01:18 -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 20:39:43 -08:00
|
|
|
func (app *DummyApplication) Query(query []byte) (code types.CodeType, result []byte, log string) {
|
|
|
|
return types.CodeType_OK, nil, "Query not supported"
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|