mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-18 17:41:19 +00:00
cmd: fixes for new config
This commit is contained in:
parent
7db7bbe464
commit
1ef7c1d25b
@ -10,7 +10,6 @@ var replayCmd = &cobra.Command{
|
||||
Use: "replay",
|
||||
Short: "Replay messages from WAL",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
config := getConfig()
|
||||
consensus.RunReplayFile(&config.Config, config.Consensus, false)
|
||||
},
|
||||
}
|
||||
@ -19,7 +18,6 @@ var replayConsoleCmd = &cobra.Command{
|
||||
Use: "replay_console",
|
||||
Short: "Replay messages from WAL in a console",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
config := getConfig()
|
||||
consensus.RunReplayFile(&config.Config, config.Consensus, true)
|
||||
},
|
||||
}
|
||||
|
@ -29,14 +29,12 @@ func init() {
|
||||
// XXX: this is totally unsafe.
|
||||
// it's only suitable for testnets.
|
||||
func resetAll(cmd *cobra.Command, args []string) {
|
||||
config := getConfig()
|
||||
ResetAll(config.DBDir, config.PrivValidatorFile, log)
|
||||
}
|
||||
|
||||
// XXX: this is totally unsafe.
|
||||
// it's only suitable for testnets.
|
||||
func resetPrivValidator(cmd *cobra.Command, args []string) {
|
||||
config := getConfig()
|
||||
resetPrivValidatorLocal(config.PrivValidatorFile, log)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
cfg "github.com/tendermint/tendermint/config/tendermint"
|
||||
"github.com/tendermint/tendermint/node"
|
||||
"github.com/tendermint/tmlibs/logger"
|
||||
)
|
||||
@ -15,8 +16,7 @@ var (
|
||||
)
|
||||
|
||||
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("")
|
||||
|
||||
}
|
||||
@ -26,21 +26,18 @@ func getConfig() *node.Config {
|
||||
return node.ConfigFromViper(viperConfig)
|
||||
}
|
||||
|
||||
//global flag
|
||||
var logLevel string
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "tendermint",
|
||||
Short: "Tendermint Core (BFT Consensus) in Go",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
// set the log level
|
||||
config := getConfig()
|
||||
config = getConfig()
|
||||
logger.SetLogLevel(config.LogLevel)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
//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"))
|
||||
}
|
||||
|
@ -19,66 +19,53 @@ var runNodeCmd = &cobra.Command{
|
||||
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() {
|
||||
// bind flags
|
||||
|
||||
// node flags
|
||||
runNodeCmd.Flags().StringVar(&moniker, "moniker", config.Moniker,
|
||||
runNodeCmd.Flags().String("moniker", config.Moniker,
|
||||
"Node Name")
|
||||
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")
|
||||
viperConfig.BindPFlag("fast_sync", runNodeCmd.Flags().Lookup("fast_sync"))
|
||||
|
||||
// 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.")
|
||||
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)")
|
||||
viperConfig.BindPFlag("abci", runNodeCmd.Flags().Lookup("abci"))
|
||||
|
||||
// rpc flags
|
||||
runNodeCmd.Flags().StringVar(&rpcLaddr, "rpc_laddr", config.RPCListenAddress,
|
||||
runNodeCmd.Flags().String("rpc_laddr", config.RPCListenAddress,
|
||||
"RPC listen address. Port required")
|
||||
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")
|
||||
viperConfig.BindPFlag("grpc_laddr", runNodeCmd.Flags().Lookup("grpc_laddr"))
|
||||
|
||||
// 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)")
|
||||
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")
|
||||
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")
|
||||
viperConfig.BindPFlag("p2p.skip_upnp", runNodeCmd.Flags().Lookup("p2p.skip_upnp"))
|
||||
|
||||
// feature flags
|
||||
runNodeCmd.Flags().BoolVar(&pex, "p2p.pex", config.P2P.PexReactor,
|
||||
runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor,
|
||||
"Enable Peer-Exchange (dev feature)")
|
||||
viperConfig.BindPFlag("p2p.pex", runNodeCmd.Flags().Lookup("p2p.pex"))
|
||||
|
||||
RootCmd.AddCommand(runNodeCmd)
|
||||
}
|
||||
@ -120,7 +107,7 @@ func runNode(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Create & start node
|
||||
n := node.NewNodeDefault(getConfig())
|
||||
n := node.NewNodeDefault(config)
|
||||
if _, err := n.Start(); err != nil {
|
||||
return fmt.Errorf("Failed to start node: %v", err)
|
||||
} else {
|
||||
|
@ -20,7 +20,6 @@ func init() {
|
||||
}
|
||||
|
||||
func showValidator(cmd *cobra.Command, args []string) {
|
||||
config := getConfig()
|
||||
privValidator := types.LoadOrGenPrivValidator(config.PrivValidatorFile)
|
||||
pubKeyJSONBytes, _ := data.ToJSON(privValidator.PubKey)
|
||||
fmt.Println(string(pubKeyJSONBytes))
|
||||
|
@ -302,6 +302,7 @@ type ConsensusState struct {
|
||||
}
|
||||
|
||||
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{
|
||||
config: config,
|
||||
proxyAppConn: proxyAppConn,
|
||||
|
Loading…
x
Reference in New Issue
Block a user