mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-10 12:01:18 +00:00
remove some more viper
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user