tendermint/example/golang/dummy.go

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