Skip to content

Commit

Permalink
fix app-db-backend config
Browse files Browse the repository at this point in the history
  • Loading branch information
roysc committed Apr 8, 2022
1 parent ef77ab2 commit 2eed35f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion db/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewDB(name string, backend BackendType, dir string) (DBConnection, error) {
for k := range backends {
keys = append(keys, string(k))
}
return nil, fmt.Errorf("unknown db_backend %s, expected one of %v",
return nil, fmt.Errorf("unknown App DB backend %s, expected one of %v",
backend, strings.Join(keys, ","))
}

Expand Down
2 changes: 1 addition & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func DefaultConfig() *Config {
MinRetainBlocks: 0,
IndexEvents: make([]string, 0),
IAVLCacheSize: 781250, // 50 MB
AppDBBackend: "",
AppDBBackend: "badgerdb",
},
Telemetry: telemetry.Config{
Enabled: false,
Expand Down
6 changes: 3 additions & 3 deletions simapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
FlagCommitValue bool
FlagOnOperationValue bool // TODO: Remove in favor of binary search for invariant violation
FlagAllInvariantsValue bool
FlagDBBackendValue string
FlagTMDBBackendValue string

FlagEnabledValue bool
FlagVerboseValue bool
Expand All @@ -47,7 +47,7 @@ func GetSimulatorFlags() {
flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit")
flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation")
flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "print all invariants if a broken invariant is found")
flag.StringVar(&FlagDBBackendValue, "DBBackend", "goleveldb", "custom db backend type")
flag.StringVar(&FlagTMDBBackendValue, "DBBackend", "badgerdb", "custom db backend type")

// simulation flags
flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation")
Expand All @@ -73,6 +73,6 @@ func NewConfigFromFlags() simulation.Config {
Commit: FlagCommitValue,
OnOperation: FlagOnOperationValue,
AllInvariants: FlagAllInvariantsValue,
DBBackend: FlagDBBackendValue,
DBBackend: FlagTMDBBackendValue,
}
}
20 changes: 3 additions & 17 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ package types
import (
"encoding/binary"
"encoding/json"
"fmt"
"time"

dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/db"
)

var (
// This is set at compile time. Could be cleveldb, defaults is goleveldb.
DBBackend = "" // Deprecated: Use tendermint config's DBBackend value instead.
backend = dbm.GoLevelDBBackend
backend = db.BadgerDBBackend
)

func init() {
if len(DBBackend) != 0 {
backend = dbm.BackendType(DBBackend)
backend = db.BackendType(DBBackend)
}
}

Expand Down Expand Up @@ -84,19 +83,6 @@ func ParseTimeBytes(bz []byte) (time.Time, error) {
return t.UTC().Round(0), nil
}

// NewLevelDB instantiate a new LevelDB instance according to DBBackend.
//
// Deprecated: Use NewDB (from "github.com/tendermint/tm-db") instead. Suggested backendType is tendermint config's DBBackend value.
func NewLevelDB(name, dir string) (db dbm.DB, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("couldn't create db: %v", r)
}
}()

return dbm.NewDB(name, backend, dir)
}

// copy bytes
func CopyBytes(bz []byte) (ret []byte) {
if bz == nil {
Expand Down

0 comments on commit 2eed35f

Please sign in to comment.