Skip to content

Commit

Permalink
fix(server(/v2): fix fallback genesis path
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 19, 2024
1 parent b1f9598 commit 70a7979
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,12 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// fallback to genesis chain-id
reader, err := os.Open(filepath.Join(homeDir, "config", "genesis.json"))
genesisPath := filepath.Join(homeDir, "config", "genesis.json")
if _, err := os.Stat(genesisPath); os.IsNotExist(err) {
genesisPath = filepath.Join(homeDir, appOpts.GetString("genesis_file"))
}

reader, err := os.Open(genesisPath)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func New[T transaction.Tx](
chainID, _ := cfg[FlagChainID].(string)
if chainID == "" {
// fallback to genesis chain-id
reader, err := os.Open(filepath.Join(home, "config", "genesis.json"))
reader, err := os.Open(srv.config.ConfigTomlConfig.GenesisFile())
if err != nil {
return nil, fmt.Errorf("failed to open genesis file: %w", err)
}
Expand Down

0 comments on commit 70a7979

Please sign in to comment.