Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add listen flag #729

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions gno.land/cmd/gnoland/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type gnolandCfg struct {
chainID string
genesisRemote string
rootDir string
rpcListenAddr string
}

func main() {
Expand Down Expand Up @@ -105,6 +106,13 @@ func (c *gnolandCfg) RegisterFlags(fs *flag.FlagSet) {
"localhost:26657",
"replacement for '%%REMOTE%%' in genesis",
)

fs.StringVar(
&c.rpcListenAddr,
"rpc.laddr",
"tcp://127.0.0.1:26657",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string is used 3 times in this file, and should be a constant. This constant should probably be located in a pkg, and not in the main.

`RPC listen address. Port required (default "tcp://127.0.0.1:26657")`,
)
}

func exec(c *gnolandCfg) error {
Expand All @@ -116,6 +124,10 @@ func exec(c *gnolandCfg) error {
cfg.Consensus.CreateEmptyBlocksInterval = 60 * time.Second
})

if c.rpcListenAddr != "tcp://127.0.0.1:26657" {
cfg.RPC.ListenAddress = c.rpcListenAddr
}
Comment on lines +127 to +129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the way to manage this. Instead, you should parse flags directly against the unmarshalled config file.


// create priv validator first.
// need it to generate genesis.json
newPrivValKey := cfg.PrivValidatorKeyFile()
Expand Down