Browse Source

cmd: fixes for new config

pull/484/head
Ethan Buchman 8 years ago
parent
commit
1ef7c1d25b
6 changed files with 18 additions and 38 deletions
  1. +0
    -2
      cmd/tendermint/commands/replay.go
  2. +0
    -2
      cmd/tendermint/commands/reset_priv_validator.go
  3. +5
    -8
      cmd/tendermint/commands/root.go
  4. +12
    -25
      cmd/tendermint/commands/run_node.go
  5. +0
    -1
      cmd/tendermint/commands/show_validator.go
  6. +1
    -0
      consensus/state.go

+ 0
- 2
cmd/tendermint/commands/replay.go View File

@ -10,7 +10,6 @@ var replayCmd = &cobra.Command{
Use: "replay", Use: "replay",
Short: "Replay messages from WAL", Short: "Replay messages from WAL",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
config := getConfig()
consensus.RunReplayFile(&config.Config, config.Consensus, false) consensus.RunReplayFile(&config.Config, config.Consensus, false)
}, },
} }
@ -19,7 +18,6 @@ var replayConsoleCmd = &cobra.Command{
Use: "replay_console", Use: "replay_console",
Short: "Replay messages from WAL in a console", Short: "Replay messages from WAL in a console",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
config := getConfig()
consensus.RunReplayFile(&config.Config, config.Consensus, true) consensus.RunReplayFile(&config.Config, config.Consensus, true)
}, },
} }


+ 0
- 2
cmd/tendermint/commands/reset_priv_validator.go View File

@ -29,14 +29,12 @@ func init() {
// XXX: this is totally unsafe. // XXX: this is totally unsafe.
// it's only suitable for testnets. // it's only suitable for testnets.
func resetAll(cmd *cobra.Command, args []string) { func resetAll(cmd *cobra.Command, args []string) {
config := getConfig()
ResetAll(config.DBDir, config.PrivValidatorFile, log) ResetAll(config.DBDir, config.PrivValidatorFile, log)
} }
// XXX: this is totally unsafe. // XXX: this is totally unsafe.
// it's only suitable for testnets. // it's only suitable for testnets.
func resetPrivValidator(cmd *cobra.Command, args []string) { func resetPrivValidator(cmd *cobra.Command, args []string) {
config := getConfig()
resetPrivValidatorLocal(config.PrivValidatorFile, log) resetPrivValidatorLocal(config.PrivValidatorFile, log)
} }


+ 5
- 8
cmd/tendermint/commands/root.go View File

@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config/tendermint"
"github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/node"
"github.com/tendermint/tmlibs/logger" "github.com/tendermint/tmlibs/logger"
) )
@ -15,8 +16,7 @@ var (
) )
func init() { func init() {
// Set config to be used as defaults by flags.
// This will be overwritten by whatever is unmarshalled from viper
viperConfig = cfg.GetConfig("")
config = node.NewDefaultConfig("") config = node.NewDefaultConfig("")
} }
@ -26,21 +26,18 @@ func getConfig() *node.Config {
return node.ConfigFromViper(viperConfig) return node.ConfigFromViper(viperConfig)
} }
//global flag
var logLevel string
var RootCmd = &cobra.Command{ var RootCmd = &cobra.Command{
Use: "tendermint", Use: "tendermint",
Short: "Tendermint Core (BFT Consensus) in Go", Short: "Tendermint Core (BFT Consensus) in Go",
PersistentPreRun: func(cmd *cobra.Command, args []string) { PersistentPreRun: func(cmd *cobra.Command, args []string) {
// set the log level // set the log level
config := getConfig()
config = getConfig()
logger.SetLogLevel(config.LogLevel) logger.SetLogLevel(config.LogLevel)
}, },
} }
func init() { func init() {
//parse flag and set config //parse flag and set config
RootCmd.PersistentFlags().StringVar(&logLevel, "log_level", config.LogLevel, "Log level")
viperConfig.BindPFlag("log_level", RootCmd.Flags().Lookup("log_level"))
RootCmd.PersistentFlags().String("log_level", config.LogLevel, "Log level")
viperConfig.BindPFlag("log_level", RootCmd.PersistentFlags().Lookup("log_level"))
} }

+ 12
- 25
cmd/tendermint/commands/run_node.go View File

@ -19,66 +19,53 @@ var runNodeCmd = &cobra.Command{
RunE: runNode, RunE: runNode,
} }
//flags
var (
moniker string
nodeLaddr string
seeds string
fastSync bool
skipUPNP bool
rpcLaddr string
grpcLaddr string
proxyApp string
abciTransport string
pex bool
)
func init() { func init() {
// bind flags // bind flags
// node flags // node flags
runNodeCmd.Flags().StringVar(&moniker, "moniker", config.Moniker,
runNodeCmd.Flags().String("moniker", config.Moniker,
"Node Name") "Node Name")
viperConfig.BindPFlag("moniker", runNodeCmd.Flags().Lookup("moniker")) viperConfig.BindPFlag("moniker", runNodeCmd.Flags().Lookup("moniker"))
runNodeCmd.Flags().BoolVar(&fastSync, "fast_sync", config.FastSync,
runNodeCmd.Flags().Bool("fast_sync", config.FastSync,
"Fast blockchain syncing") "Fast blockchain syncing")
viperConfig.BindPFlag("fast_sync", runNodeCmd.Flags().Lookup("fast_sync")) viperConfig.BindPFlag("fast_sync", runNodeCmd.Flags().Lookup("fast_sync"))
// abci flags // abci flags
runNodeCmd.Flags().StringVar(&proxyApp, "proxy_app", config.ProxyApp,
runNodeCmd.Flags().String("proxy_app", config.ProxyApp,
"Proxy app address, or 'nilapp' or 'dummy' for local testing.") "Proxy app address, or 'nilapp' or 'dummy' for local testing.")
viperConfig.BindPFlag("proxy_app", runNodeCmd.Flags().Lookup("proxy_app")) viperConfig.BindPFlag("proxy_app", runNodeCmd.Flags().Lookup("proxy_app"))
runNodeCmd.Flags().StringVar(&abciTransport, "abci", config.ABCI,
runNodeCmd.Flags().String("abci", config.ABCI,
"Specify abci transport (socket | grpc)") "Specify abci transport (socket | grpc)")
viperConfig.BindPFlag("abci", runNodeCmd.Flags().Lookup("abci")) viperConfig.BindPFlag("abci", runNodeCmd.Flags().Lookup("abci"))
// rpc flags // rpc flags
runNodeCmd.Flags().StringVar(&rpcLaddr, "rpc_laddr", config.RPCListenAddress,
runNodeCmd.Flags().String("rpc_laddr", config.RPCListenAddress,
"RPC listen address. Port required") "RPC listen address. Port required")
viperConfig.BindPFlag("rpc_laddr", runNodeCmd.Flags().Lookup("rpc_laddr")) viperConfig.BindPFlag("rpc_laddr", runNodeCmd.Flags().Lookup("rpc_laddr"))
runNodeCmd.Flags().StringVar(&grpcLaddr, "grpc_laddr", config.GRPCListenAddress,
runNodeCmd.Flags().String("grpc_laddr", config.GRPCListenAddress,
"GRPC listen address (BroadcastTx only). Port required") "GRPC listen address (BroadcastTx only). Port required")
viperConfig.BindPFlag("grpc_laddr", runNodeCmd.Flags().Lookup("grpc_laddr")) viperConfig.BindPFlag("grpc_laddr", runNodeCmd.Flags().Lookup("grpc_laddr"))
// p2p flags // p2p flags
runNodeCmd.Flags().StringVar(&nodeLaddr, "p2p.laddr", config.P2P.ListenAddress,
runNodeCmd.Flags().String("p2p.laddr", config.P2P.ListenAddress,
"Node listen address. (0.0.0.0:0 means any interface, any port)") "Node listen address. (0.0.0.0:0 means any interface, any port)")
viperConfig.BindPFlag("p2p.laddr", runNodeCmd.Flags().Lookup("p2p.laddr")) viperConfig.BindPFlag("p2p.laddr", runNodeCmd.Flags().Lookup("p2p.laddr"))
runNodeCmd.Flags().StringVar(&seeds, "p2p.seeds", config.P2P.Seeds,
runNodeCmd.Flags().String("p2p.seeds", config.P2P.Seeds,
"Comma delimited host:port seed nodes") "Comma delimited host:port seed nodes")
viperConfig.BindPFlag("p2p.seeds", runNodeCmd.Flags().Lookup("p2p.seeds")) viperConfig.BindPFlag("p2p.seeds", runNodeCmd.Flags().Lookup("p2p.seeds"))
runNodeCmd.Flags().BoolVar(&skipUPNP, "p2p.skip_upnp", config.P2P.SkipUPNP,
runNodeCmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP,
"Skip UPNP configuration") "Skip UPNP configuration")
viperConfig.BindPFlag("p2p.skip_upnp", runNodeCmd.Flags().Lookup("p2p.skip_upnp")) viperConfig.BindPFlag("p2p.skip_upnp", runNodeCmd.Flags().Lookup("p2p.skip_upnp"))
// feature flags // feature flags
runNodeCmd.Flags().BoolVar(&pex, "p2p.pex", config.P2P.PexReactor,
runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor,
"Enable Peer-Exchange (dev feature)") "Enable Peer-Exchange (dev feature)")
viperConfig.BindPFlag("p2p.pex", runNodeCmd.Flags().Lookup("p2p.pex"))
RootCmd.AddCommand(runNodeCmd) RootCmd.AddCommand(runNodeCmd)
} }
@ -120,7 +107,7 @@ func runNode(cmd *cobra.Command, args []string) error {
} }
// Create & start node // Create & start node
n := node.NewNodeDefault(getConfig())
n := node.NewNodeDefault(config)
if _, err := n.Start(); err != nil { if _, err := n.Start(); err != nil {
return fmt.Errorf("Failed to start node: %v", err) return fmt.Errorf("Failed to start node: %v", err)
} else { } else {


+ 0
- 1
cmd/tendermint/commands/show_validator.go View File

@ -20,7 +20,6 @@ func init() {
} }
func showValidator(cmd *cobra.Command, args []string) { func showValidator(cmd *cobra.Command, args []string) {
config := getConfig()
privValidator := types.LoadOrGenPrivValidator(config.PrivValidatorFile) privValidator := types.LoadOrGenPrivValidator(config.PrivValidatorFile)
pubKeyJSONBytes, _ := data.ToJSON(privValidator.PubKey) pubKeyJSONBytes, _ := data.ToJSON(privValidator.PubKey)
fmt.Println(string(pubKeyJSONBytes)) fmt.Println(string(pubKeyJSONBytes))


+ 1
- 0
consensus/state.go View File

@ -302,6 +302,7 @@ type ConsensusState struct {
} }
func NewConsensusState(config *Config, state *sm.State, proxyAppConn proxy.AppConnConsensus, blockStore types.BlockStore, mempool types.Mempool) *ConsensusState { func NewConsensusState(config *Config, state *sm.State, proxyAppConn proxy.AppConnConsensus, blockStore types.BlockStore, mempool types.Mempool) *ConsensusState {
config.chainID = state.ChainID // Set ChainID
cs := &ConsensusState{ cs := &ConsensusState{
config: config, config: config,
proxyAppConn: proxyAppConn, proxyAppConn: proxyAppConn,


Loading…
Cancel
Save