diff --git a/cmd/tendermint/commands/reset_priv_validator.go b/cmd/tendermint/commands/reset_priv_validator.go index a611935b..448a1869 100644 --- a/cmd/tendermint/commands/reset_priv_validator.go +++ b/cmd/tendermint/commands/reset_priv_validator.go @@ -4,7 +4,6 @@ import ( "os" "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/tendermint/log15" "github.com/tendermint/tendermint/types" @@ -30,36 +29,34 @@ func init() { // XXX: this is totally unsafe. // it's only suitable for testnets. func resetAll(cmd *cobra.Command, args []string) { - ResetAll(config, log) + ResetAll(config.GetString("db_dir"), config.GetString("priv_validator_file"), log) } // XXX: this is totally unsafe. // it's only suitable for testnets. func resetPrivValidator(cmd *cobra.Command, args []string) { - resetPrivValidatorLocal(config, log) + resetPrivValidatorLocal(config.GetString("priv_validator_file"), log) } // Exported so other CLI tools can use it -func ResetAll(c *viper.Viper, l log15.Logger) { - resetPrivValidatorLocal(c, l) - dataDir := c.GetString("db_dir") - os.RemoveAll(dataDir) - l.Notice("Removed all data", "dir", dataDir) +func ResetAll(dbDir, privValFile string, l log15.Logger) { + resetPrivValidatorLocal(privValFile, l) + os.RemoveAll(dbDir) + l.Notice("Removed all data", "dir", dbDir) } -func resetPrivValidatorLocal(c *viper.Viper, l log15.Logger) { +func resetPrivValidatorLocal(privValFile string, l log15.Logger) { // Get PrivValidator var privValidator *types.PrivValidator - privValidatorFile := c.GetString("priv_validator_file") - if _, err := os.Stat(privValidatorFile); err == nil { - privValidator = types.LoadPrivValidator(privValidatorFile) + if _, err := os.Stat(privValFile); err == nil { + privValidator = types.LoadPrivValidator(privValFile) privValidator.Reset() - l.Notice("Reset PrivValidator", "file", privValidatorFile) + l.Notice("Reset PrivValidator", "file", privValFile) } else { privValidator = types.GenPrivValidator() - privValidator.SetFile(privValidatorFile) + privValidator.SetFile(privValFile) privValidator.Save() - l.Notice("Generated PrivValidator", "file", privValidatorFile) + l.Notice("Generated PrivValidator", "file", privValFile) } } diff --git a/consensus/replay.go b/consensus/replay.go index ecb29e3d..01199007 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -10,8 +10,6 @@ import ( "strings" "time" - "github.com/spf13/viper" - abci "github.com/tendermint/abci/types" "github.com/tendermint/go-wire" auto "github.com/tendermint/tmlibs/autofile" @@ -200,15 +198,14 @@ func makeHeightSearchFunc(height int) auto.SearchFunc { // we were last and using the WAL to recover there type Handshaker struct { - config *viper.Viper - state *sm.State - store types.BlockStore + state *sm.State + store types.BlockStore nBlocks int // number of blocks applied to the state } -func NewHandshaker(config *viper.Viper, state *sm.State, store types.BlockStore) *Handshaker { - return &Handshaker{config, state, store, 0} +func NewHandshaker(state *sm.State, store types.BlockStore) *Handshaker { + return &Handshaker{state, store, 0} } func (h *Handshaker) NBlocks() int { diff --git a/consensus/replay_file.go b/consensus/replay_file.go index 9bcfafe6..1f4de893 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -247,7 +247,7 @@ func newConsensusStateForReplay(config *viper.Viper) *ConsensusState { // Create proxyAppConn connection (consensus, mempool, query) clientCreator := proxy.DefaultClientCreator(config.GetString("proxy_app"), config.GetString("abci"), config.GetString("db_dir")) - proxyApp := proxy.NewAppConns(clientCreator, NewHandshaker(config, state, blockStore)) + proxyApp := proxy.NewAppConns(clientCreator, NewHandshaker(state, blockStore)) _, err := proxyApp.Start() if err != nil { cmn.Exit(cmn.Fmt("Error starting proxy app conns: %v", err)) diff --git a/node/node.go b/node/node.go index 4b344ffc..764c89b8 100644 --- a/node/node.go +++ b/node/node.go @@ -85,7 +85,7 @@ func NewNode(config *viper.Viper, privValidator *types.PrivValidator, clientCrea // Create the proxyApp, which manages connections (consensus, mempool, query) // and sync tendermint and the app by replaying any necessary blocks - proxyApp := proxy.NewAppConns(clientCreator, consensus.NewHandshaker(config, state, blockStore)) + proxyApp := proxy.NewAppConns(clientCreator, consensus.NewHandshaker(state, blockStore)) if _, err := proxyApp.Start(); err != nil { cmn.Exit(cmn.Fmt("Error starting proxy app connections: %v", err)) }