This commit is contained in:
Ethan Frey 2017-10-16 18:14:55 +02:00
parent df0f3a22da
commit adab86c947
3 changed files with 12 additions and 16 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/errors" "github.com/cosmos/cosmos-sdk/errors"
sm "github.com/cosmos/cosmos-sdk/state" sm "github.com/cosmos/cosmos-sdk/state"
"github.com/cosmos/cosmos-sdk/version"
) )
//nolint //nolint
@ -29,6 +28,10 @@ const (
// It should be embeded in another struct for CheckTx, // It should be embeded in another struct for CheckTx,
// DeliverTx and initializing state from the genesis. // DeliverTx and initializing state from the genesis.
type BaseApp struct { type BaseApp struct {
// Name is what is returned from info
Name string
// this is the database state
info *sm.ChainState info *sm.ChainState
*sm.State *sm.State
@ -42,12 +45,13 @@ type BaseApp struct {
} }
// NewBaseApp creates a data store to handle queries // NewBaseApp creates a data store to handle queries
func NewBaseApp(dbName string, cacheSize int, logger log.Logger) (*BaseApp, error) { func NewBaseApp(appName, dbName string, cacheSize int, logger log.Logger) (*BaseApp, error) {
state, err := loadState(dbName, cacheSize) state, err := loadState(dbName, cacheSize)
if err != nil { if err != nil {
return nil, err return nil, err
} }
app := &BaseApp{ app := &BaseApp{
Name: appName,
State: state, State: state,
height: state.LatestHeight(), height: state.LatestHeight(),
info: sm.NewChainState(), info: sm.NewChainState(),
@ -84,7 +88,7 @@ func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo {
return abci.ResponseInfo{ return abci.ResponseInfo{
// TODO // TODO
Data: fmt.Sprintf("Basecoin v%v", version.Version), Data: app.Name,
LastBlockHeight: app.height, LastBlockHeight: app.height,
LastBlockAppHash: hash, LastBlockAppHash: hash,
} }

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/abci/version"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tmlibs/log"
sdk "github.com/cosmos/cosmos-sdk" sdk "github.com/cosmos/cosmos-sdk"
@ -26,7 +27,8 @@ var _ abci.Application = &Basecoin{}
// NewBasecoin - create a new instance of the basecoin application // NewBasecoin - create a new instance of the basecoin application
func NewBasecoin(handler sdk.Handler, dbName string, cacheSize int, logger log.Logger) (*Basecoin, error) { func NewBasecoin(handler sdk.Handler, dbName string, cacheSize int, logger log.Logger) (*Basecoin, error) {
base, err := NewBaseApp(dbName, cacheSize, logger) appName := fmt.Sprintf("Basecoin v%v", version.Version)
base, err := NewBaseApp(appName, dbName, cacheSize, logger)
app := &Basecoin{ app := &Basecoin{
BaseApp: base, BaseApp: base,
handler: handler, handler: handler,
@ -36,7 +38,8 @@ func NewBasecoin(handler sdk.Handler, dbName string, cacheSize int, logger log.L
// NewBasecoinTick - create a new instance of the basecoin application with tick functionality // NewBasecoinTick - create a new instance of the basecoin application with tick functionality
func NewBasecoinTick(handler sdk.Handler, tick Ticker, dbName string, cacheSize int, logger log.Logger) (*Basecoin, error) { func NewBasecoinTick(handler sdk.Handler, tick Ticker, dbName string, cacheSize int, logger log.Logger) (*Basecoin, error) {
base, err := NewBaseApp(dbName, cacheSize, logger) appName := fmt.Sprintf("Basecoin v%v", version.Version)
base, err := NewBaseApp(appName, dbName, cacheSize, logger)
app := &Basecoin{ app := &Basecoin{
BaseApp: base, BaseApp: base,
handler: handler, handler: handler,

View File

@ -1,11 +0,0 @@
package app
// // MockStore returns an in-memory store only intended for testing
// func MockStore() *Store {
// res, err := NewStore("", 0, log.NewNopLogger())
// if err != nil {
// // should never happen, abort test if it does
// panic(err)
// }
// return res
// }