Don't require init when --trust-node is given

This commit is contained in:
Ethan Frey
2017-07-29 17:23:21 -04:00
parent b98bfc01ae
commit 8dd2371cc5
3 changed files with 27 additions and 16 deletions
+9 -3
View File
@@ -29,9 +29,10 @@ var (
//nolint
const (
SeedFlag = "seed"
HashFlag = "valhash"
GenesisFlag = "genesis"
SeedFlag = "seed"
HashFlag = "valhash"
GenesisFlag = "genesis"
FlagTrustNode = "trust-node"
ConfigFile = "config.toml"
)
@@ -125,6 +126,11 @@ type Runable func(cmd *cobra.Command, args []string) error
// and the root command sets up viper, which is needed to find the home dir.
func RequireInit(run Runable) Runable {
return func(cmd *cobra.Command, args []string) error {
// otherwise, run the wrappped command
if viper.GetBool(FlagTrustNode) {
return run(cmd, args)
}
// first check if we were Init'ed and if not, return an error
root := viper.GetString(cli.HomeFlag)
init, err := WasInited(root)
+6 -2
View File
@@ -1,6 +1,9 @@
package proofs
import "github.com/spf13/cobra"
import (
"github.com/spf13/cobra"
"github.com/tendermint/basecoin/client/commands"
)
// nolint
const (
@@ -22,5 +25,6 @@ data to other peers as needed.
func init() {
RootCmd.Flags().Int(FlagHeight, 0, "Height to query (skip to use latest block)")
RootCmd.Flags().Bool(FlagTrustNode, false, "DANGEROUS: blindly trust all results from the server")
RootCmd.Flags().Bool(commands.FlagTrustNode, false,
"DANGEROUS: blindly trust all results from the server")
}