mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 04:01:55 +00:00
Config is passed into each module. Remove tendermint/confer
This commit is contained in:
@@ -118,7 +118,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Write pid to file. This should be the last thing before TrapSignal.
|
||||
err = AtomicWriteFile(barak.rootDir+"/pidfile", []byte(Fmt("%v", barak.pid)))
|
||||
err = WriteFileAtomic(barak.rootDir+"/pidfile", []byte(Fmt("%v", barak.pid)))
|
||||
if err != nil {
|
||||
panic(Fmt("Error writing pidfile: %v", err))
|
||||
}
|
||||
|
13
cmd/tendermint/config.go
Normal file
13
cmd/tendermint/config.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
var config cfg.Config = nil
|
||||
|
||||
func init() {
|
||||
cfg.OnConfig(func(newConfig cfg.Config) {
|
||||
config = newConfig
|
||||
})
|
||||
}
|
43
cmd/tendermint/flags.go
Normal file
43
cmd/tendermint/flags.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
flag "github.com/spf13/pflag"
|
||||
"os"
|
||||
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
func parseFlags(config cfg.Config, args []string) {
|
||||
var (
|
||||
printHelp bool
|
||||
moniker string
|
||||
nodeLaddr string
|
||||
seeds string
|
||||
fastSync bool
|
||||
rpcLaddr string
|
||||
logLevel string
|
||||
)
|
||||
|
||||
// Declare flags
|
||||
var flags = flag.NewFlagSet("main", flag.ExitOnError)
|
||||
flags.BoolVar(&printHelp, "help", false, "Print this help message.")
|
||||
flags.StringVar(&moniker, "moniker", config.GetString("moniker"), "Node Name")
|
||||
flags.StringVar(&nodeLaddr, "node_laddr", config.GetString("node_laddr"), "Node listen address. (0.0.0.0:0 means any interface, any port)")
|
||||
flags.StringVar(&seeds, "seeds", config.GetString("seeds"), "Comma delimited seed nodes")
|
||||
flags.BoolVar(&fastSync, "fast_sync", config.GetBool("fast_sync"), "Fast blockchain syncing")
|
||||
flags.StringVar(&rpcLaddr, "rpc_laddr", config.GetString("rpc_laddr"), "RPC listen address. Port required")
|
||||
flags.StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level")
|
||||
flags.Parse(args)
|
||||
if printHelp {
|
||||
flags.PrintDefaults()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Merge parsed flag values onto app.
|
||||
config.Set("moniker", moniker)
|
||||
config.Set("node_laddr", nodeLaddr)
|
||||
config.Set("seeds", seeds)
|
||||
config.Set("fast_sync", fastSync)
|
||||
config.Set("rpc_laddr", rpcLaddr)
|
||||
config.Set("log_level", logLevel)
|
||||
}
|
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
@@ -18,7 +17,7 @@ Paste the following JSON into your %v file
|
||||
%v
|
||||
|
||||
`,
|
||||
config.App().GetString("priv_validator_file"),
|
||||
config.GetString("priv_validator_file"),
|
||||
string(privValidatorJSONBytes),
|
||||
)
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/logger"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
||||
"github.com/tendermint/tendermint/node"
|
||||
)
|
||||
|
||||
@@ -25,18 +25,19 @@ Commands:
|
||||
return
|
||||
}
|
||||
|
||||
// Get configuration
|
||||
config := tmcfg.GetConfig("")
|
||||
parseFlags(config, args[1:]) // Command line overrides
|
||||
cfg.ApplyConfig(config) // Notify modules of new config
|
||||
|
||||
switch args[0] {
|
||||
case "node":
|
||||
config.ParseFlags(args[1:])
|
||||
logger.Reset()
|
||||
node.RunNode()
|
||||
case "gen_account":
|
||||
gen_account()
|
||||
case "gen_validator":
|
||||
gen_validator()
|
||||
case "gen_tx":
|
||||
config.ParseFlags(args[1:])
|
||||
logger.Reset()
|
||||
gen_tx()
|
||||
case "probe_upnp":
|
||||
probe_upnp()
|
||||
|
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/tendermint/config"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
func reset_priv_validator() {
|
||||
// Get PrivValidator
|
||||
var privValidator *sm.PrivValidator
|
||||
privValidatorFile := config.App().GetString("priv_validator_file")
|
||||
privValidatorFile := config.GetString("priv_validator_file")
|
||||
if _, err := os.Stat(privValidatorFile); err == nil {
|
||||
privValidator = sm.LoadPrivValidator(privValidatorFile)
|
||||
privValidator.LastHeight = 0
|
||||
|
Reference in New Issue
Block a user