Skip to content

Commit

Permalink
fix: use proper db backend type when reading chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Feb 27, 2024
1 parent f7dc97b commit 5c9d7cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// read the chainID from home directory (either from comet or genesis).
chainId, err := readChainIdFromHome(homeDir)
dbBackend := cast.ToString(appOpts.Get("db_backend"))
chainId, err := readChainIdFromHome(homeDir, dbBackend)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -503,9 +504,10 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
}

// readChainIdFromHome reads chain id from home directory.
func readChainIdFromHome(homeDir string) (string, error) {
func readChainIdFromHome(homeDir string, dbBackend string) (string, error) {
cfg := tmcfg.DefaultConfig()
cfg.SetRoot(homeDir)
cfg.BaseConfig.DBBackend = dbBackend

// if the node's current height is not zero then try to read the chainID from comet db.
db, err := node.DefaultDBProvider(&node.DBContext{ID: "blockstore", Config: cfg})
Expand Down

0 comments on commit 5c9d7cc

Please sign in to comment.