mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
remove viper from proxy
This commit is contained in:
@ -246,7 +246,8 @@ func newConsensusStateForReplay(config *viper.Viper) *ConsensusState {
|
|||||||
state := sm.MakeGenesisStateFromFile(stateDB, config.GetString("genesis_file"))
|
state := sm.MakeGenesisStateFromFile(stateDB, config.GetString("genesis_file"))
|
||||||
|
|
||||||
// Create proxyAppConn connection (consensus, mempool, query)
|
// Create proxyAppConn connection (consensus, mempool, query)
|
||||||
proxyApp := proxy.NewAppConns(config, proxy.DefaultClientCreator(config), NewHandshaker(config, state, blockStore))
|
clientCreator := proxy.DefaultClientCreator(config.GetString("proxy_app"), config.GetString("abci"), config.GetString("db_dir"))
|
||||||
|
proxyApp := proxy.NewAppConns(clientCreator, NewHandshaker(config, state, blockStore))
|
||||||
_, err := proxyApp.Start()
|
_, err := proxyApp.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmn.Exit(cmn.Fmt("Error starting proxy app conns: %v", err))
|
cmn.Exit(cmn.Fmt("Error starting proxy app conns: %v", err))
|
||||||
|
@ -62,7 +62,11 @@ func NewNodeDefault(config *viper.Viper) *Node {
|
|||||||
// Get PrivValidator
|
// Get PrivValidator
|
||||||
privValidatorFile := config.GetString("priv_validator_file")
|
privValidatorFile := config.GetString("priv_validator_file")
|
||||||
privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
|
privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
|
||||||
return NewNode(config, privValidator, proxy.DefaultClientCreator(config))
|
return NewNode(config, privValidator, proxy.DefaultClientCreator(
|
||||||
|
config.GetString("proxy_app"),
|
||||||
|
config.GetString("abci"),
|
||||||
|
config.GetString("db_dir"),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNode(config *viper.Viper, privValidator *types.PrivValidator, clientCreator proxy.ClientCreator) *Node {
|
func NewNode(config *viper.Viper, privValidator *types.PrivValidator, clientCreator proxy.ClientCreator) *Node {
|
||||||
@ -81,7 +85,7 @@ func NewNode(config *viper.Viper, privValidator *types.PrivValidator, clientCrea
|
|||||||
|
|
||||||
// Create the proxyApp, which manages connections (consensus, mempool, query)
|
// Create the proxyApp, which manages connections (consensus, mempool, query)
|
||||||
// and sync tendermint and the app by replaying any necessary blocks
|
// and sync tendermint and the app by replaying any necessary blocks
|
||||||
proxyApp := proxy.NewAppConns(config, clientCreator, consensus.NewHandshaker(config, state, blockStore))
|
proxyApp := proxy.NewAppConns(clientCreator, consensus.NewHandshaker(config, state, blockStore))
|
||||||
if _, err := proxyApp.Start(); err != nil {
|
if _, err := proxyApp.Start(); err != nil {
|
||||||
cmn.Exit(cmn.Fmt("Error starting proxy app connections: %v", err))
|
cmn.Exit(cmn.Fmt("Error starting proxy app connections: %v", err))
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
abcicli "github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/example/dummy"
|
"github.com/tendermint/abci/example/dummy"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
@ -64,15 +62,12 @@ func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) {
|
|||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// default
|
// default
|
||||||
|
|
||||||
func DefaultClientCreator(config *viper.Viper) ClientCreator {
|
func DefaultClientCreator(addr, transport, dbDir string) ClientCreator {
|
||||||
addr := config.GetString("proxy_app")
|
|
||||||
transport := config.GetString("abci")
|
|
||||||
|
|
||||||
switch addr {
|
switch addr {
|
||||||
case "dummy":
|
case "dummy":
|
||||||
return NewLocalClientCreator(dummy.NewDummyApplication())
|
return NewLocalClientCreator(dummy.NewDummyApplication())
|
||||||
case "persistent_dummy":
|
case "persistent_dummy":
|
||||||
return NewLocalClientCreator(dummy.NewPersistentDummyApplication(config.GetString("db_dir")))
|
return NewLocalClientCreator(dummy.NewPersistentDummyApplication(dbDir))
|
||||||
case "nilapp":
|
case "nilapp":
|
||||||
return NewLocalClientCreator(types.NewBaseApplication())
|
return NewLocalClientCreator(types.NewBaseApplication())
|
||||||
default:
|
default:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,8 +15,8 @@ type AppConns interface {
|
|||||||
Query() AppConnQuery
|
Query() AppConnQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppConns(config *viper.Viper, clientCreator ClientCreator, handshaker Handshaker) AppConns {
|
func NewAppConns(clientCreator ClientCreator, handshaker Handshaker) AppConns {
|
||||||
return NewMultiAppConn(config, clientCreator, handshaker)
|
return NewMultiAppConn(clientCreator, handshaker)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
@ -34,8 +33,6 @@ type Handshaker interface {
|
|||||||
type multiAppConn struct {
|
type multiAppConn struct {
|
||||||
cmn.BaseService
|
cmn.BaseService
|
||||||
|
|
||||||
config *viper.Viper
|
|
||||||
|
|
||||||
handshaker Handshaker
|
handshaker Handshaker
|
||||||
|
|
||||||
mempoolConn *appConnMempool
|
mempoolConn *appConnMempool
|
||||||
@ -46,9 +43,8 @@ type multiAppConn struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make all necessary abci connections to the application
|
// Make all necessary abci connections to the application
|
||||||
func NewMultiAppConn(config *viper.Viper, clientCreator ClientCreator, handshaker Handshaker) *multiAppConn {
|
func NewMultiAppConn(clientCreator ClientCreator, handshaker Handshaker) *multiAppConn {
|
||||||
multiAppConn := &multiAppConn{
|
multiAppConn := &multiAppConn{
|
||||||
config: config,
|
|
||||||
handshaker: handshaker,
|
handshaker: handshaker,
|
||||||
clientCreator: clientCreator,
|
clientCreator: clientCreator,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user