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-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) Echo(message string) string {
|
2015-11-09 16:29:45 -08:00
|
|
|
return message
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) Info() []string {
|
|
|
|
return []string{Fmt("size:%v", app.state.Size())}
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) SetOption(key string, value string) types.RetCode {
|
2015-11-27 10:14:46 -08:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode) {
|
|
|
|
app.state.Set(tx, tx)
|
2015-11-16 15:50:26 -08:00
|
|
|
return nil, 0
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) CheckTx(tx []byte) types.RetCode {
|
|
|
|
return 0 // all txs are valid
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) GetHash() ([]byte, types.RetCode) {
|
|
|
|
hash := app.state.Hash()
|
|
|
|
return hash, 0
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) AddListener(key string) types.RetCode {
|
2015-11-02 07:39:53 -08:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
func (app *DummyApplication) RemListener(key string) types.RetCode {
|
2015-11-02 07:39:53 -08:00
|
|
|
return 0
|
|
|
|
}
|