Accept relative paths in all configs, TODO: must SetRoot

This commit is contained in:
Ethan Frey
2017-05-04 21:57:58 +02:00
committed by Ethan Buchman
parent 92dee7ea3c
commit 6b059e0063
10 changed files with 96 additions and 49 deletions

View File

@@ -20,13 +20,13 @@ func init() {
}
func initFiles(cmd *cobra.Command, args []string) {
privValFile := config.PrivValidatorFile
privValFile := config.PrivValidatorFile()
if _, err := os.Stat(privValFile); os.IsNotExist(err) {
privValidator := types.GenPrivValidator()
privValidator.SetFile(privValFile)
privValidator.Save()
genFile := config.GenesisFile
genFile := config.GenesisFile()
if _, err := os.Stat(genFile); os.IsNotExist(err) {
genDoc := types.GenesisDoc{

View File

@@ -29,13 +29,13 @@ func init() {
// XXX: this is totally unsafe.
// it's only suitable for testnets.
func resetAll(cmd *cobra.Command, args []string) {
ResetAll(config.DBDir, config.PrivValidatorFile, log)
ResetAll(config.DBDir(), config.PrivValidatorFile(), log)
}
// XXX: this is totally unsafe.
// it's only suitable for testnets.
func resetPrivValidator(cmd *cobra.Command, args []string) {
resetPrivValidatorLocal(config.PrivValidatorFile, log)
resetPrivValidatorLocal(config.PrivValidatorFile(), log)
}
// Exported so other CLI tools can use it

View File

@@ -14,7 +14,7 @@ var (
)
func init() {
config = cfg.DefaultConfig("REMOVE-ROOT")
config = cfg.DefaultConfig()
RootCmd.PersistentFlags().String("log_level", config.LogLevel, "Log level")
}

View File

@@ -56,7 +56,7 @@ func runNode(cmd *cobra.Command, args []string) error {
// This is for Mintnet compatibility.
// TODO: If Mintnet gets deprecated or genesis_file is
// always available, remove.
genDocFile := config.GenesisFile
genDocFile := config.GenesisFile()
if !cmn.FileExists(genDocFile) {
log.Notice(cmn.Fmt("Waiting for genesis file %v...", genDocFile))
for {

View File

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