Skip to content

Commit

Permalink
add initial height flag to cli init cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
fragwuerdig committed Feb 24, 2023
1 parent 407c757 commit 6a45baf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const (
FlagReverse = "reverse"
FlagTip = "tip"
FlagAux = "aux"
FlagInitHeight = "initial-height"
// FlagOutput is the flag to set the output format.
// This differs from FlagOutputDocument that is used to set the output file.
FlagOutput = cmtcli.OutputFlag
Expand Down
8 changes: 8 additions & 0 deletions x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
}
}

// Get initial height
initHeight, err := cmd.Flags().GetInt64(flags.FlagInitHeight)
if initHeight < 1 {
initHeight = 1
}

nodeID, _, err := genutil.InitializeNodeValidatorFilesFromMnemonic(config, mnemonic)
if err != nil {
return err
Expand Down Expand Up @@ -148,6 +154,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
genDoc.ChainID = chainID
genDoc.Validators = nil
genDoc.AppState = appState
genDoc.InitialHeight = initHeight

if err = genutil.ExportGenesisFile(genDoc, genFile); err != nil {
return errors.Wrap(err, "Failed to export genesis file")
Expand All @@ -165,6 +172,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating")
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(FlagDefaultBondDenom, "", "genesis file default denomination, if left blank default value is 'stake'")
cmd.Flags().Int64(flags.FlagInitHeight, 1, "specify the initial block height at genesis")

return cmd
}

0 comments on commit 6a45baf

Please sign in to comment.