mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 17:31:34 +00:00
Commands compile (mostly) with new config reading
This commit is contained in:
committed by
Ethan Buchman
parent
604bf03f3a
commit
92dee7ea3c
@ -10,7 +10,7 @@ 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) {
|
||||||
consensus.RunReplayFile(&config.Config, config.Consensus, false)
|
consensus.RunReplayFile(config.BaseConfig, config.Consensus, false)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ 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) {
|
||||||
consensus.RunReplayFile(&config.Config, config.Consensus, true)
|
consensus.RunReplayFile(config.BaseConfig, config.Consensus, true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,38 +4,26 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
cfg "github.com/tendermint/tendermint/config/tendermint"
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
"github.com/tendermint/tendermint/node"
|
|
||||||
"github.com/tendermint/tmlibs/logger"
|
"github.com/tendermint/tmlibs/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
viperConfig *viper.Viper
|
config *cfg.Config
|
||||||
config *node.Config
|
log = logger.New("module", "main")
|
||||||
log = logger.New("module", "main")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
viperConfig = cfg.GetConfig("")
|
config = cfg.DefaultConfig("REMOVE-ROOT")
|
||||||
}
|
RootCmd.PersistentFlags().String("log_level", config.LogLevel, "Log level")
|
||||||
|
|
||||||
// unmarshal viper into the Tendermint config
|
|
||||||
func getConfig() *node.Config {
|
|
||||||
return node.ConfigFromViper(viperConfig)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
// set the log level
|
err := viper.Unmarshal(config)
|
||||||
config = getConfig()
|
|
||||||
logger.SetLogLevel(config.LogLevel)
|
logger.SetLogLevel(config.LogLevel)
|
||||||
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
//parse flag and set config
|
|
||||||
RootCmd.PersistentFlags().String("log_level", viperConfig.GetString("log_level"), "Log level")
|
|
||||||
viperConfig.BindPFlag("log_level", RootCmd.PersistentFlags().Lookup("log_level"))
|
|
||||||
}
|
|
||||||
|
@ -18,38 +18,28 @@ var runNodeCmd = &cobra.Command{
|
|||||||
RunE: runNode,
|
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() {
|
func init() {
|
||||||
// bind flags
|
// bind flags
|
||||||
|
runNodeCmd.Flags().String("moniker", config.Moniker, "Node Name")
|
||||||
|
|
||||||
// node flags
|
// node flags
|
||||||
registerRunNodeFlagString("moniker", "Node Name")
|
runNodeCmd.Flags().Bool("fast_sync", config.FastSync, "Fast blockchain syncing")
|
||||||
registerRunNodeFlagBool("fast_sync", "Fast blockchain syncing")
|
|
||||||
|
|
||||||
// abci flags
|
// abci flags
|
||||||
registerRunNodeFlagString("proxy_app", "Proxy app address, or 'nilapp' or 'dummy' for local testing.")
|
runNodeCmd.Flags().String("proxy_app", config.ProxyApp, "Proxy app address, or 'nilapp' or 'dummy' for local testing.")
|
||||||
registerRunNodeFlagString("abci", "Specify abci transport (socket | grpc)")
|
runNodeCmd.Flags().String("abci", config.ABCI, "Specify abci transport (socket | grpc)")
|
||||||
|
|
||||||
// rpc flags
|
// rpc flags
|
||||||
registerRunNodeFlagString("rpc_laddr", "RPC listen address. Port required")
|
runNodeCmd.Flags().String("rpc_laddr", config.RPCListenAddress, "RPC listen address. Port required")
|
||||||
registerRunNodeFlagString("grpc_laddr", "GRPC listen address (BroadcastTx only). Port required")
|
runNodeCmd.Flags().String("grpc_laddr", config.GRPCListenAddress, "GRPC listen address (BroadcastTx only). Port required")
|
||||||
|
|
||||||
// p2p flags
|
// p2p flags
|
||||||
registerRunNodeFlagString("p2p.laddr", "Node listen address. (0.0.0.0:0 means any interface, any port)")
|
runNodeCmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)")
|
||||||
registerRunNodeFlagString("p2p.seeds", "Comma delimited host:port seed nodes")
|
runNodeCmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma delimited host:port seed nodes")
|
||||||
registerRunNodeFlagBool("p2p.skip_upnp", "Skip UPNP configuration")
|
runNodeCmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration")
|
||||||
|
|
||||||
// feature flags
|
// feature flags
|
||||||
registerRunNodeFlagBool("p2p.pex", "Enable Peer-Exchange (dev feature)")
|
runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable Peer-Exchange (dev feature)")
|
||||||
|
|
||||||
RootCmd.AddCommand(runNodeCmd)
|
RootCmd.AddCommand(runNodeCmd)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/cmd/tendermint/commands"
|
"github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
|
"github.com/tendermint/tmlibs/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := commands.RootCmd.Execute(); err != nil {
|
cmd := cli.PrepareBaseCmd(commands.RootCmd, "TM", os.ExpandEnv("$HOME/.tendermint"))
|
||||||
fmt.Println(err)
|
cmd.Execute()
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
// replay messages interactively or all at once
|
// replay messages interactively or all at once
|
||||||
|
|
||||||
func RunReplayFile(config *cfg.Config, csConfig *cfg.ConsensusConfig, console bool) {
|
func RunReplayFile(config *cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console bool) {
|
||||||
consensusState := newConsensusStateForReplay(config, csConfig)
|
consensusState := newConsensusStateForReplay(config, csConfig)
|
||||||
|
|
||||||
if err := consensusState.ReplayFile(csConfig.WalFile, console); err != nil {
|
if err := consensusState.ReplayFile(csConfig.WalFile, console); err != nil {
|
||||||
@ -235,7 +235,7 @@ func (pb *playback) replayConsoleLoop() int {
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
// convenience for replay mode
|
// convenience for replay mode
|
||||||
func newConsensusStateForReplay(config *cfg.Config, csConfig *cfg.ConsensusConfig) *ConsensusState {
|
func newConsensusStateForReplay(config *cfg.BaseConfig, csConfig *cfg.ConsensusConfig) *ConsensusState {
|
||||||
// Get BlockStore
|
// Get BlockStore
|
||||||
blockStoreDB := dbm.NewDB("blockstore", config.DBBackend, config.DBDir)
|
blockStoreDB := dbm.NewDB("blockstore", config.DBBackend, config.DBDir)
|
||||||
blockStore := bc.NewBlockStore(blockStoreDB)
|
blockStore := bc.NewBlockStore(blockStoreDB)
|
||||||
|
Reference in New Issue
Block a user