From f4cf45e17af53f84698044a62454046ae8f39585 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Wed, 30 Jan 2019 16:49:14 -0800 Subject: [PATCH] Merge PR #3453: Make rest-server respect persistent flags --- PENDING.md | 2 ++ client/flags.go | 8 +------- client/lcd/root.go | 7 +++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/PENDING.md b/PENDING.md index fe0d438fabbf..531509b0039b 100644 --- a/PENDING.md +++ b/PENDING.md @@ -68,6 +68,8 @@ BUG FIXES https://github.com/ZondaX/ledger-cosmos-go/commit/ed9aa39ce8df31bad1448c72d3d226bf2cb1a8d1 in order to fix a derivation path issue that causes `gaiacli keys add --recover` to malfunction. - [\#3419](https://github.com/cosmos/cosmos-sdk/pull/3419) Fix `q distr slashes` panic + - [\#3453](https://github.com/cosmos/cosmos-sdk/pull/3453) The `rest-server` command didn't respect persistent flags such as `--chain-id` and `--trust-node` if they were + passed on the command line. * Gaia diff --git a/client/flags.go b/client/flags.go index 9ee121c2096c..0c5d3423a1b0 100644 --- a/client/flags.go +++ b/client/flags.go @@ -103,21 +103,15 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command { // RegisterRestServerFlags registers the flags required for rest server func RegisterRestServerFlags(cmd *cobra.Command) *cobra.Command { + cmd = GetCommands(cmd)[0] cmd.Flags().String(FlagListenAddr, "tcp://localhost:1317", "The address for the server to listen on") cmd.Flags().Bool(FlagInsecure, false, "Do not set up SSL/TLS layer") cmd.Flags().String(FlagSSLHosts, "", "Comma-separated hostnames and IPs to generate a certificate for") cmd.Flags().String(FlagSSLCertFile, "", "Path to a SSL certificate file. If not supplied, a self-signed certificate will be generated.") cmd.Flags().String(FlagSSLKeyFile, "", "Path to a key file; ignored if a certificate file is not supplied.") cmd.Flags().String(FlagCORS, "", "Set the domains that can make CORS requests (* for all)") - cmd.Flags().String(FlagChainID, "", "Chain ID of Tendermint node") - cmd.Flags().String(FlagNode, "tcp://localhost:26657", "Address of the node to connect to") cmd.Flags().Int(FlagMaxOpenConnections, 1000, "The number of maximum open connections") - cmd.Flags().Bool(FlagTrustNode, false, "Trust connected full node (don't verify proofs for responses)") - cmd.Flags().Bool(FlagIndentResponse, false, "Add indent to JSON response") - viper.BindPFlag(FlagTrustNode, cmd.Flags().Lookup(FlagTrustNode)) - viper.BindPFlag(FlagChainID, cmd.Flags().Lookup(FlagChainID)) - viper.BindPFlag(FlagNode, cmd.Flags().Lookup(FlagNode)) return cmd } diff --git a/client/lcd/root.go b/client/lcd/root.go index 07aade96b332..8014fdd92789 100644 --- a/client/lcd/root.go +++ b/client/lcd/root.go @@ -84,7 +84,8 @@ func (rs *RestServer) Start(listenAddr string, sslHosts string, if err != nil { return } - rs.log.Info("Starting Gaia Lite REST service...") + rs.log.Info(fmt.Sprintf("Starting Gaia Lite REST service (chain-id: %q)...", + viper.GetString(client.FlagChainID))) // launch rest-server in insecure mode if insecure { @@ -151,9 +152,7 @@ func ServeCommand(cdc *codec.Codec, registerRoutesFn func(*RestServer)) *cobra.C }, } - client.RegisterRestServerFlags(cmd) - - return cmd + return client.RegisterRestServerFlags(cmd) } func (rs *RestServer) registerSwaggerUI() {