Skip to content

Commit

Permalink
feat: 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 4c51b77 commit 63dd7e8
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 @@ -107,6 +107,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 @@ -151,6 +157,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
appGenesis.AppVersion = version.Version
appGenesis.ChainID = chainID
appGenesis.AppState = appState
appGenesis.InitialHeight = initHeight
appGenesis.Consensus = &types.ConsensusGenesis{
Validators: nil,
}
Expand All @@ -171,6 +178,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 63dd7e8

Please sign in to comment.