Skip to content

Commit

Permalink
simplify some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jan 29, 2024
1 parent 7e9bc41 commit 3305767
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

"cosmossdk.io/tools/rosetta"
crgserver "cosmossdk.io/tools/rosetta/lib/server"
cfg "github.com/cometbft/cometbft/config"
cmtjson "github.com/cometbft/cometbft/libs/json"
cmtstate "github.com/cometbft/cometbft/proto/tendermint/state"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand Down Expand Up @@ -278,24 +277,10 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
return err
}

isTestnet, ok := ctx.Viper.Get(KeyIsTestnet).(bool)
if !ok {
isTestnet = false
}

var app types.Application

if isTestnet {
newChainID, ok := ctx.Viper.Get(KeyNewChainID).(string)
if !ok {
return fmt.Errorf("expected string for key %s", KeyNewChainID)
}
newOperatorAddress, ok := ctx.Viper.Get(KeyNewOpAddr).(string)
if !ok {
return fmt.Errorf("expected string for key %s", KeyNewOpAddr)
}

app, err = testnetify(ctx, cfg, home, newChainID, newOperatorAddress, appCreator, db)
if isTestnet, ok := ctx.Viper.Get(KeyIsTestnet).(bool); ok && isTestnet {
app, err = testnetify(ctx, home, appCreator, db)
if err != nil {
return err
}
Expand Down Expand Up @@ -684,7 +669,14 @@ before stopping the daemon.

// testnetify modifies both state and blockStore, allowing the provided operator address and local validator key to control the network
// that the state in the data folder represents. The chainID of the local genesis file is modified to match the provided chainID.
func testnetify(ctx *Context, config *cfg.Config, home, newChainID, newOperatorAddress string, testnetAppCreator types.AppCreator, db db.DB) (types.Application, error) {
func testnetify(ctx *Context, home string, testnetAppCreator types.AppCreator, db db.DB) (types.Application, error) {
config := ctx.Config

newChainID, ok := ctx.Viper.Get(KeyNewChainID).(string)
if !ok {
return nil, fmt.Errorf("expected string for key %s", KeyNewChainID)
}

traceWriterFile := ctx.Viper.GetString(flagTraceStore)
traceWriter, err := openTraceWriter(traceWriterFile)
if err != nil {
Expand Down

0 comments on commit 3305767

Please sign in to comment.