Browse Source

cleanup run_node flags

pull/484/head
Ethan Buchman 8 years ago
parent
commit
f217f2b2c5
2 changed files with 22 additions and 41 deletions
  1. +1
    -3
      cmd/tendermint/commands/root.go
  2. +21
    -38
      cmd/tendermint/commands/run_node.go

+ 1
- 3
cmd/tendermint/commands/root.go View File

@ -17,8 +17,6 @@ var (
func init() {
viperConfig = cfg.GetConfig("")
config = node.NewDefaultConfig("")
}
// unmarshal viper into the Tendermint config
@ -38,6 +36,6 @@ var RootCmd = &cobra.Command{
func init() {
//parse flag and set config
RootCmd.PersistentFlags().String("log_level", config.LogLevel, "Log level")
RootCmd.PersistentFlags().String("log_level", viperConfig.GetString("log_level"), "Log level")
viperConfig.BindPFlag("log_level", RootCmd.PersistentFlags().Lookup("log_level"))
}

+ 21
- 38
cmd/tendermint/commands/run_node.go View File

@ -7,7 +7,6 @@ import (
"github.com/spf13/cobra"
//cfg "github.com/tendermint/tendermint/config/tendermint"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common"
@ -19,53 +18,38 @@ var runNodeCmd = &cobra.Command{
RunE: runNode,
}
func registerRunNodeFlagString(flagName, desc string) {
runNodeCmd.Flags().String(flagName, viperConfig.GetString(flagName), desc)
viperConfig.BindPFlag(flagName, runNodeCmd.Flags().Lookup(flagName))
}
func registerRunNodeFlagBool(flagName, desc string) {
runNodeCmd.Flags().Bool(flagName, viperConfig.GetBool(flagName), desc)
viperConfig.BindPFlag(flagName, runNodeCmd.Flags().Lookup(flagName))
}
func init() {
// bind flags
// node flags
runNodeCmd.Flags().String("moniker", config.Moniker,
"Node Name")
viperConfig.BindPFlag("moniker", runNodeCmd.Flags().Lookup("moniker"))
runNodeCmd.Flags().Bool("fast_sync", config.FastSync,
"Fast blockchain syncing")
viperConfig.BindPFlag("fast_sync", runNodeCmd.Flags().Lookup("fast_sync"))
registerRunNodeFlagString("moniker", "Node Name")
registerRunNodeFlagBool("fast_sync", "Fast blockchain syncing")
// abci flags
runNodeCmd.Flags().String("proxy_app", config.ProxyApp,
"Proxy app address, or 'nilapp' or 'dummy' for local testing.")
viperConfig.BindPFlag("proxy_app", runNodeCmd.Flags().Lookup("proxy_app"))
runNodeCmd.Flags().String("abci", config.ABCI,
"Specify abci transport (socket | grpc)")
viperConfig.BindPFlag("abci", runNodeCmd.Flags().Lookup("abci"))
registerRunNodeFlagString("proxy_app", "Proxy app address, or 'nilapp' or 'dummy' for local testing.")
registerRunNodeFlagString("abci", "Specify abci transport (socket | grpc)")
// rpc flags
runNodeCmd.Flags().String("rpc_laddr", config.RPCListenAddress,
"RPC listen address. Port required")
viperConfig.BindPFlag("rpc_laddr", runNodeCmd.Flags().Lookup("rpc_laddr"))
runNodeCmd.Flags().String("grpc_laddr", config.GRPCListenAddress,
"GRPC listen address (BroadcastTx only). Port required")
viperConfig.BindPFlag("grpc_laddr", runNodeCmd.Flags().Lookup("grpc_laddr"))
registerRunNodeFlagString("rpc_laddr", "RPC listen address. Port required")
registerRunNodeFlagString("grpc_laddr", "GRPC listen address (BroadcastTx only). Port required")
// p2p flags
runNodeCmd.Flags().String("p2p.laddr", config.P2P.ListenAddress,
"Node listen address. (0.0.0.0:0 means any interface, any port)")
viperConfig.BindPFlag("p2p.laddr", runNodeCmd.Flags().Lookup("p2p.laddr"))
runNodeCmd.Flags().String("p2p.seeds", config.P2P.Seeds,
"Comma delimited host:port seed nodes")
viperConfig.BindPFlag("p2p.seeds", runNodeCmd.Flags().Lookup("p2p.seeds"))
runNodeCmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP,
"Skip UPNP configuration")
viperConfig.BindPFlag("p2p.skip_upnp", runNodeCmd.Flags().Lookup("p2p.skip_upnp"))
registerRunNodeFlagString("p2p.laddr", "Node listen address. (0.0.0.0:0 means any interface, any port)")
registerRunNodeFlagString("p2p.seeds", "Comma delimited host:port seed nodes")
registerRunNodeFlagBool("p2p.skip_upnp", "Skip UPNP configuration")
// feature flags
runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor,
"Enable Peer-Exchange (dev feature)")
viperConfig.BindPFlag("p2p.pex", runNodeCmd.Flags().Lookup("p2p.pex"))
registerRunNodeFlagBool("p2p.pex", "Enable Peer-Exchange (dev feature)")
RootCmd.AddCommand(runNodeCmd)
}
@ -101,8 +85,7 @@ func runNode(cmd *cobra.Command, args []string) error {
if genDoc.ChainID == "" {
return fmt.Errorf("Genesis doc %v must include non-empty chain_id", genDocFile)
}
// config.SetChainID("chain_id", genDoc.ChainID) TODO
config.ChainID = genDoc.ChainID
}
}


Loading…
Cancel
Save