Swap all examples & testcases to use automatic DB namespacing
This commit is contained in:
parent
62112eab17
commit
49b8978454
|
@ -11,6 +11,7 @@ BREAKING CHANGES
|
||||||
|
|
||||||
* Remove go-wire, use go-amino
|
* Remove go-wire, use go-amino
|
||||||
* [store] Add `SubspaceIterator` and `ReverseSubspaceIterator` to `KVStore` interface
|
* [store] Add `SubspaceIterator` and `ReverseSubspaceIterator` to `KVStore` interface
|
||||||
|
* [basecoin] NewBasecoinApp takes a `dbm.DB` and uses namespaced DBs for substores
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
|
|
@ -71,21 +71,20 @@ func (app *BaseApp) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount a store to the provided key in the BaseApp multistore
|
// Mount a store to the provided key in the BaseApp multistore
|
||||||
// Broken until #532 is implemented.
|
|
||||||
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
|
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
app.MountStore(key, sdk.StoreTypeIAVL)
|
app.MountStore(key, sdk.StoreTypeIAVL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount a store to the provided key in the BaseApp multistore
|
// Mount a store to the provided key in the BaseApp multistore, using a specified DB
|
||||||
func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
|
func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
|
||||||
app.cms.MountStoreWithDB(key, typ, db)
|
app.cms.MountStoreWithDB(key, typ, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount a store to the provided key in the BaseApp multistore
|
// Mount a store to the provided key in the BaseApp multistore, using the default DB
|
||||||
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
|
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
|
||||||
app.cms.MountStoreWithDB(key, typ, app.db)
|
app.cms.MountStoreWithDB(key, typ, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint - Set functions
|
// nolint - Set functions
|
||||||
|
|
|
@ -35,15 +35,12 @@ func TestMountStores(t *testing.T) {
|
||||||
|
|
||||||
// make some cap keys
|
// make some cap keys
|
||||||
capKey1 := sdk.NewKVStoreKey("key1")
|
capKey1 := sdk.NewKVStoreKey("key1")
|
||||||
db1 := dbm.NewMemDB()
|
|
||||||
capKey2 := sdk.NewKVStoreKey("key2")
|
capKey2 := sdk.NewKVStoreKey("key2")
|
||||||
db2 := dbm.NewMemDB()
|
|
||||||
|
|
||||||
// no stores are mounted
|
// no stores are mounted
|
||||||
assert.Panics(t, func() { app.LoadLatestVersion(capKey1) })
|
assert.Panics(t, func() { app.LoadLatestVersion(capKey1) })
|
||||||
|
|
||||||
app.MountStoreWithDB(capKey1, sdk.StoreTypeIAVL, db1)
|
app.MountStoresIAVL(capKey1, capKey2)
|
||||||
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
|
||||||
|
|
||||||
// stores are mounted
|
// stores are mounted
|
||||||
err := app.LoadLatestVersion(capKey1)
|
err := app.LoadLatestVersion(capKey1)
|
||||||
|
@ -155,11 +152,8 @@ func TestInitChainer(t *testing.T) {
|
||||||
// NOTE/TODO: mounting multiple stores is broken
|
// NOTE/TODO: mounting multiple stores is broken
|
||||||
// see https://github.com/cosmos/cosmos-sdk/issues/532
|
// see https://github.com/cosmos/cosmos-sdk/issues/532
|
||||||
capKey := sdk.NewKVStoreKey("main")
|
capKey := sdk.NewKVStoreKey("main")
|
||||||
db1 := dbm.NewMemDB()
|
|
||||||
capKey2 := sdk.NewKVStoreKey("key2")
|
capKey2 := sdk.NewKVStoreKey("key2")
|
||||||
db2 := dbm.NewMemDB()
|
app.MountStoresIAVL(capKey, capKey2)
|
||||||
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
|
|
||||||
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
|
||||||
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
@ -191,8 +185,7 @@ func TestInitChainer(t *testing.T) {
|
||||||
|
|
||||||
// reload app
|
// reload app
|
||||||
app = NewBaseApp(name, logger, db)
|
app = NewBaseApp(name, logger, db)
|
||||||
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
|
app.MountStoresIAVL(capKey, capKey2)
|
||||||
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
|
||||||
err = app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
err = app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
app.SetInitChainer(initChainer)
|
app.SetInitChainer(initChainer)
|
||||||
|
|
|
@ -333,13 +333,8 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
|
||||||
// logger = log.NewFilter(logger, log.AllowError())
|
// logger = log.NewFilter(logger, log.AllowError())
|
||||||
privValidatorFile := config.PrivValidatorFile()
|
privValidatorFile := config.PrivValidatorFile()
|
||||||
privVal := pvm.LoadOrGenFilePV(privValidatorFile)
|
privVal := pvm.LoadOrGenFilePV(privValidatorFile)
|
||||||
dbs := map[string]dbm.DB{
|
db := dbm.NewMemDB()
|
||||||
"main": dbm.NewMemDB(),
|
app := bapp.NewBasecoinApp(logger, db)
|
||||||
"acc": dbm.NewMemDB(),
|
|
||||||
"ibc": dbm.NewMemDB(),
|
|
||||||
"staking": dbm.NewMemDB(),
|
|
||||||
}
|
|
||||||
app := bapp.NewBasecoinApp(logger, dbs)
|
|
||||||
cdc = bapp.MakeCodec() // XXX
|
cdc = bapp.MakeCodec() // XXX
|
||||||
|
|
||||||
genesisFile := config.GenesisFile()
|
genesisFile := config.GenesisFile()
|
||||||
|
|
|
@ -28,29 +28,11 @@ var (
|
||||||
// TODO: distinguish from basecoin
|
// TODO: distinguish from basecoin
|
||||||
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||||
dataDir := filepath.Join(rootDir, "data")
|
dataDir := filepath.Join(rootDir, "data")
|
||||||
dbMain, err := dbm.NewGoLevelDB("gaia", dataDir)
|
db, err := dbm.NewGoLevelDB("gaia", dataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dbAcc, err := dbm.NewGoLevelDB("gaia-acc", dataDir)
|
bapp := app.NewBasecoinApp(logger, db)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbIBC, err := dbm.NewGoLevelDB("gaia-ibc", dataDir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbStaking, err := dbm.NewGoLevelDB("gaia-staking", dataDir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbs := map[string]dbm.DB{
|
|
||||||
"main": dbMain,
|
|
||||||
"acc": dbAcc,
|
|
||||||
"ibc": dbIBC,
|
|
||||||
"staking": dbStaking,
|
|
||||||
}
|
|
||||||
bapp := app.NewBasecoinApp(logger, dbs)
|
|
||||||
return bapp, nil
|
return bapp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,14 @@ type BasecoinApp struct {
|
||||||
accountMapper sdk.AccountMapper
|
accountMapper sdk.AccountMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBasecoinApp(logger log.Logger, dbs map[string]dbm.DB) *BasecoinApp {
|
func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||||
|
|
||||||
// Create app-level codec for txs and accounts.
|
// Create app-level codec for txs and accounts.
|
||||||
var cdc = MakeCodec()
|
var cdc = MakeCodec()
|
||||||
|
|
||||||
// Create your application object.
|
// Create your application object.
|
||||||
var app = &BasecoinApp{
|
var app = &BasecoinApp{
|
||||||
BaseApp: bam.NewBaseApp(appName, logger, dbs["main"]),
|
BaseApp: bam.NewBaseApp(appName, logger, db),
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
||||||
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
||||||
|
@ -72,12 +72,7 @@ func NewBasecoinApp(logger log.Logger, dbs map[string]dbm.DB) *BasecoinApp {
|
||||||
// Initialize BaseApp.
|
// Initialize BaseApp.
|
||||||
app.SetTxDecoder(app.txDecoder)
|
app.SetTxDecoder(app.txDecoder)
|
||||||
app.SetInitChainer(app.initChainer)
|
app.SetInitChainer(app.initChainer)
|
||||||
app.MountStoreWithDB(app.capKeyMainStore, sdk.StoreTypeIAVL, dbs["main"])
|
app.MountStoresIAVL(app.capKeyMainStore, app.capKeyAccountStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
||||||
app.MountStoreWithDB(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbs["acc"])
|
|
||||||
app.MountStoreWithDB(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbs["ibc"])
|
|
||||||
app.MountStoreWithDB(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbs["staking"])
|
|
||||||
// NOTE: Broken until #532 lands
|
|
||||||
//app.MountStoresIAVL(app.capKeyMainStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
|
||||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
||||||
err := app.LoadLatestVersion(app.capKeyMainStore)
|
err := app.LoadLatestVersion(app.capKeyMainStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -85,20 +85,15 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func loggerAndDBs() (log.Logger, map[string]dbm.DB) {
|
func loggerAndDB() (log.Logger, dbm.DB) {
|
||||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
||||||
dbs := map[string]dbm.DB{
|
db := dbm.NewMemDB()
|
||||||
"main": dbm.NewMemDB(),
|
return logger, db
|
||||||
"acc": dbm.NewMemDB(),
|
|
||||||
"ibc": dbm.NewMemDB(),
|
|
||||||
"staking": dbm.NewMemDB(),
|
|
||||||
}
|
|
||||||
return logger, dbs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBasecoinApp() *BasecoinApp {
|
func newBasecoinApp() *BasecoinApp {
|
||||||
logger, dbs := loggerAndDBs()
|
logger, db := loggerAndDB()
|
||||||
return NewBasecoinApp(logger, dbs)
|
return NewBasecoinApp(logger, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setGenesisAccounts(bapp *BasecoinApp, accs ...auth.BaseAccount) error {
|
func setGenesisAccounts(bapp *BasecoinApp, accs ...auth.BaseAccount) error {
|
||||||
|
@ -142,8 +137,8 @@ func TestMsgs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortGenesis(t *testing.T) {
|
func TestSortGenesis(t *testing.T) {
|
||||||
logger, dbs := loggerAndDBs()
|
logger, db := loggerAndDB()
|
||||||
bapp := NewBasecoinApp(logger, dbs)
|
bapp := NewBasecoinApp(logger, db)
|
||||||
|
|
||||||
// Note the order: the coins are unsorted!
|
// Note the order: the coins are unsorted!
|
||||||
coinDenom1, coinDenom2 := "foocoin", "barcoin"
|
coinDenom1, coinDenom2 := "foocoin", "barcoin"
|
||||||
|
@ -184,8 +179,8 @@ func TestSortGenesis(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
logger, dbs := loggerAndDBs()
|
logger, db := loggerAndDB()
|
||||||
bapp := NewBasecoinApp(logger, dbs)
|
bapp := NewBasecoinApp(logger, db)
|
||||||
|
|
||||||
// Construct some genesis bytes to reflect basecoin/types/AppAccount
|
// Construct some genesis bytes to reflect basecoin/types/AppAccount
|
||||||
pk := crypto.GenPrivKeyEd25519().PubKey()
|
pk := crypto.GenPrivKeyEd25519().PubKey()
|
||||||
|
@ -207,7 +202,7 @@ func TestGenesis(t *testing.T) {
|
||||||
assert.Equal(t, acc, res1)
|
assert.Equal(t, acc, res1)
|
||||||
|
|
||||||
// reload app and ensure the account is still there
|
// reload app and ensure the account is still there
|
||||||
bapp = NewBasecoinApp(logger, dbs)
|
bapp = NewBasecoinApp(logger, db)
|
||||||
ctx = bapp.BaseApp.NewContext(true, abci.Header{})
|
ctx = bapp.BaseApp.NewContext(true, abci.Header{})
|
||||||
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
||||||
assert.Equal(t, acc, res1)
|
assert.Equal(t, acc, res1)
|
||||||
|
|
|
@ -27,29 +27,11 @@ var (
|
||||||
|
|
||||||
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||||
dataDir := filepath.Join(rootDir, "data")
|
dataDir := filepath.Join(rootDir, "data")
|
||||||
dbMain, err := dbm.NewGoLevelDB("basecoin", dataDir)
|
db, err := dbm.NewGoLevelDB("basecoin", dataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dbAcc, err := dbm.NewGoLevelDB("basecoin-acc", dataDir)
|
bapp := app.NewBasecoinApp(logger, db)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbIBC, err := dbm.NewGoLevelDB("basecoin-ibc", dataDir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbStaking, err := dbm.NewGoLevelDB("basecoin-staking", dataDir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbs := map[string]dbm.DB{
|
|
||||||
"main": dbMain,
|
|
||||||
"acc": dbAcc,
|
|
||||||
"ibc": dbIBC,
|
|
||||||
"staking": dbStaking,
|
|
||||||
}
|
|
||||||
bapp := app.NewBasecoinApp(logger, dbs)
|
|
||||||
return bapp, nil
|
return bapp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,14 @@ type DemocoinApp struct {
|
||||||
accountMapper sdk.AccountMapper
|
accountMapper sdk.AccountMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemocoinApp(logger log.Logger, dbs map[string]dbm.DB) *DemocoinApp {
|
func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||||
|
|
||||||
// Create app-level codec for txs and accounts.
|
// Create app-level codec for txs and accounts.
|
||||||
var cdc = MakeCodec()
|
var cdc = MakeCodec()
|
||||||
|
|
||||||
// Create your application object.
|
// Create your application object.
|
||||||
var app = &DemocoinApp{
|
var app = &DemocoinApp{
|
||||||
BaseApp: bam.NewBaseApp(appName, logger, dbs["main"]),
|
BaseApp: bam.NewBaseApp(appName, logger, db),
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
||||||
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
||||||
|
@ -82,13 +82,7 @@ func NewDemocoinApp(logger log.Logger, dbs map[string]dbm.DB) *DemocoinApp {
|
||||||
// Initialize BaseApp.
|
// Initialize BaseApp.
|
||||||
app.SetTxDecoder(app.txDecoder)
|
app.SetTxDecoder(app.txDecoder)
|
||||||
app.SetInitChainer(app.initChainerFn(coolKeeper, powKeeper))
|
app.SetInitChainer(app.initChainerFn(coolKeeper, powKeeper))
|
||||||
app.MountStoreWithDB(app.capKeyMainStore, sdk.StoreTypeIAVL, dbs["main"])
|
app.MountStoresIAVL(app.capKeyMainStore, app.capKeyAccountStore, app.capKeyPowStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
||||||
app.MountStoreWithDB(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbs["acc"])
|
|
||||||
app.MountStoreWithDB(app.capKeyPowStore, sdk.StoreTypeIAVL, dbs["pow"])
|
|
||||||
app.MountStoreWithDB(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbs["ibc"])
|
|
||||||
app.MountStoreWithDB(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbs["staking"])
|
|
||||||
// NOTE: Broken until #532 lands
|
|
||||||
//app.MountStoresIAVL(app.capKeyMainStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
|
||||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
||||||
err := app.LoadLatestVersion(app.capKeyMainStore)
|
err := app.LoadLatestVersion(app.capKeyMainStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -67,21 +67,15 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func loggerAndDBs() (log.Logger, map[string]dbm.DB) {
|
func loggerAndDB() (log.Logger, dbm.DB) {
|
||||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
||||||
dbs := map[string]dbm.DB{
|
db := dbm.NewMemDB()
|
||||||
"main": dbm.NewMemDB(),
|
return logger, db
|
||||||
"acc": dbm.NewMemDB(),
|
|
||||||
"pow": dbm.NewMemDB(),
|
|
||||||
"ibc": dbm.NewMemDB(),
|
|
||||||
"staking": dbm.NewMemDB(),
|
|
||||||
}
|
|
||||||
return logger, dbs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDemocoinApp() *DemocoinApp {
|
func newDemocoinApp() *DemocoinApp {
|
||||||
logger, dbs := loggerAndDBs()
|
logger, db := loggerAndDB()
|
||||||
return NewDemocoinApp(logger, dbs)
|
return NewDemocoinApp(logger, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
//_______________________________________________________________________
|
//_______________________________________________________________________
|
||||||
|
@ -123,8 +117,8 @@ func TestMsgs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
logger, dbs := loggerAndDBs()
|
logger, db := loggerAndDB()
|
||||||
bapp := NewDemocoinApp(logger, dbs)
|
bapp := NewDemocoinApp(logger, db)
|
||||||
|
|
||||||
// Construct some genesis bytes to reflect democoin/types/AppAccount
|
// Construct some genesis bytes to reflect democoin/types/AppAccount
|
||||||
pk := crypto.GenPrivKeyEd25519().PubKey()
|
pk := crypto.GenPrivKeyEd25519().PubKey()
|
||||||
|
@ -157,7 +151,7 @@ func TestGenesis(t *testing.T) {
|
||||||
assert.Equal(t, acc, res1)
|
assert.Equal(t, acc, res1)
|
||||||
|
|
||||||
// reload app and ensure the account is still there
|
// reload app and ensure the account is still there
|
||||||
bapp = NewDemocoinApp(logger, dbs)
|
bapp = NewDemocoinApp(logger, db)
|
||||||
ctx = bapp.BaseApp.NewContext(true, abci.Header{})
|
ctx = bapp.BaseApp.NewContext(true, abci.Header{})
|
||||||
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
||||||
assert.Equal(t, acc, res1)
|
assert.Equal(t, acc, res1)
|
||||||
|
|
|
@ -47,34 +47,11 @@ func defaultAppState(args []string, addr sdk.Address, coinDenom string) (json.Ra
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||||
dbMain, err := dbm.NewGoLevelDB("democoin", filepath.Join(rootDir, "data"))
|
db, err := dbm.NewGoLevelDB("democoin", filepath.Join(rootDir, "data"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dbAcc, err := dbm.NewGoLevelDB("democoin-acc", filepath.Join(rootDir, "data"))
|
bapp := app.NewDemocoinApp(logger, db)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbPow, err := dbm.NewGoLevelDB("democoin-pow", filepath.Join(rootDir, "data"))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbIBC, err := dbm.NewGoLevelDB("democoin-ibc", filepath.Join(rootDir, "data"))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbStaking, err := dbm.NewGoLevelDB("democoin-staking", filepath.Join(rootDir, "data"))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dbs := map[string]dbm.DB{
|
|
||||||
"main": dbMain,
|
|
||||||
"acc": dbAcc,
|
|
||||||
"pow": dbPow,
|
|
||||||
"ibc": dbIBC,
|
|
||||||
"staking": dbStaking,
|
|
||||||
}
|
|
||||||
bapp := app.NewDemocoinApp(logger, dbs)
|
|
||||||
return bapp, nil
|
return bapp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue