Skip to content

Commit

Permalink
let users customise node's IP
Browse files Browse the repository at this point in the history
Plus, make gaiad init's --moniker turn
into a required argument.

closes: #3497
  • Loading branch information
Alessio Treglia committed Feb 5, 2019
1 parent 5e35354 commit 98e82ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ BREAKING CHANGES
- `--insecure` flag is removed.
- `--tls` is now used to enable secure layer.
- [\#3451](https://github.com/cosmos/cosmos-sdk/pull/3451) `gaiacli` now returns transactions in plain text including tags.
- [\#3497](https://github.com/cosmos/cosmos-sdk/issues/3497) `gaiad init` now takes moniker as required arguments, not as parameter.

* Gaia
* [\#3457](https://github.com/cosmos/cosmos-sdk/issues/3457) Changed governance tally validatorGovInfo to use sdk.Int power instead of sdk.Dec
Expand Down Expand Up @@ -60,6 +61,7 @@ IMPROVEMENTS

* Gaia CLI (`gaiacli`)
* [\#3476](https://github.com/cosmos/cosmos-sdk/issues/3476) New `withdraw-all-rewards` command to withdraw all delegations rewards for delegators.
- [\#3497](https://github.com/cosmos/cosmos-sdk/issues/3497) `gaiad gentx` supports `--ip` flag to take a custom ip address.

* Gaia
* [\#3418](https://github.com/cosmos/cosmos-sdk/issues/3418) Add vesting account
Expand Down
12 changes: 8 additions & 4 deletions cmd/gaia/init/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ following delegation and commission default parameters:
return err
}

ip, err := server.ExternalIP()
if err != nil {
fmt.Fprintf(os.Stderr, "couldn't retrieve an external IP, "+
"consequently the tx's memo field will be unset: %s", err)
ip := viper.GetString(cli.FlagIP)
if ip == "" {
ip, err = server.ExternalIP()
if err != nil {
fmt.Fprintf(os.Stderr, "couldn't retrieve an external IP, "+
"consequently the tx's memo field will be unset: %s", err)
}
}

genDoc, err := LoadGenesisDoc(cdc, config.GenesisFile())
Expand Down Expand Up @@ -161,6 +164,7 @@ following delegation and commission default parameters:
cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx")
cmd.Flags().String(client.FlagOutputDocument, "",
"write the genesis transaction JSON document to the given file instead of the default location")
cmd.Flags().String(cli.FlagIP, "", "The node's public IP.")
cmd.Flags().AddFlagSet(cli.FsCommissionCreate)
cmd.Flags().AddFlagSet(cli.FsAmount)
cmd.Flags().AddFlagSet(cli.FsPk)
Expand Down
11 changes: 4 additions & 7 deletions cmd/gaia/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
const (
flagOverwrite = "overwrite"
flagClientHome = "home-client"
flagMoniker = "moniker"
)

type printInfo struct {
Expand All @@ -46,11 +45,11 @@ func displayInfo(cdc *codec.Codec, info printInfo) error {
// nolint
func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "init",
Use: "init [moniker]",
Short: "Initialize private validator, p2p, genesis, and application configuration files",
Long: `Initialize validators's and node's configuration files.`,
Args: cobra.NoArgs,
RunE: func(_ *cobra.Command, _ []string) error {
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
config := ctx.Config
config.SetRoot(viper.GetString(cli.HomeFlag))

Expand All @@ -64,7 +63,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
return err
}

config.Moniker = viper.GetString(flagMoniker)
config.Moniker = args[0]

var appState json.RawMessage
genFile := config.GenesisFile()
Expand All @@ -89,8 +88,6 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
cmd.Flags().String(cli.HomeFlag, app.DefaultNodeHome, "node's home directory")
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(flagMoniker, "", "set the validator's moniker")
cmd.MarkFlagRequired(flagMoniker)

return cmd
}
2 changes: 1 addition & 1 deletion docs/gaia/deploy-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This guide helps you create a single validator node that runs a network locally
cd $HOME

# Initialize the genesis.json file that will help you to bootstrap the network
gaiad init --chain-id testing --moniker testing
gaiad init --chain-id=testing testing

# Create a key to hold your validator account
gaiacli keys add validator
Expand Down
4 changes: 2 additions & 2 deletions docs/gaia/join-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ These instructions are for setting up a brand new full node from scratch.
First, initialize the node and create the necessary config files:

```bash
gaiad init --moniker <your_custom_moniker>
gaiad init <your_custom_moniker>
```

::: warning Note
Only ASCII characters are supported for the `--moniker`. Using Unicode characters will render your node unreachable.
Monikers can contain only Only ASCII characters. Using Unicode characters will render your node unreachable.
:::

You can edit this `moniker` later, in the `~/.gaiad/config/config.toml` file:
Expand Down

0 comments on commit 98e82ff

Please sign in to comment.