Browse Source

query conn

pull/266/head
Ethan Buchman 8 years ago
parent
commit
d9205a85d5
2 changed files with 28 additions and 2 deletions
  1. +4
    -2
      node/node.go
  2. +24
    -0
      proxy/multi_app_conn.go

+ 4
- 2
node/node.go View File

@ -41,6 +41,7 @@ type Node struct {
privValidator *types.PrivValidator privValidator *types.PrivValidator
genesisDoc *types.GenesisDoc genesisDoc *types.GenesisDoc
privKey crypto.PrivKeyEd25519 privKey crypto.PrivKeyEd25519
proxyApp proxy.AppConns
} }
func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node { func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node {
@ -59,7 +60,7 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node {
// Create the proxyApp, which houses two connections, // Create the proxyApp, which houses two connections,
// one for the consensus and one for the mempool. // one for the consensus and one for the mempool.
proxyApp := proxy.NewMultiAppConn(config, state, blockStore)
proxyApp := proxy.NewAppConns(config, state, blockStore)
// add the chainid and number of validators to the global config // add the chainid and number of validators to the global config
config.Set("chain_id", state.ChainID) config.Set("chain_id", state.ChainID)
@ -136,6 +137,7 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node {
privValidator: privValidator, privValidator: privValidator,
genesisDoc: state.GenesisDoc, genesisDoc: state.GenesisDoc,
privKey: privKey, privKey: privKey,
proxyApp: proxyApp,
} }
} }
@ -362,7 +364,7 @@ func newConsensusState(config cfg.Config) *consensus.ConsensusState {
// Create two proxyAppConn connections, // Create two proxyAppConn connections,
// one for the consensus and one for the mempool. // one for the consensus and one for the mempool.
proxyApp := proxy.NewMultiAppConn(config, state, blockStore)
proxyApp := proxy.NewAppConns(config, state, blockStore)
// add the chainid to the global config // add the chainid to the global config
config.Set("chain_id", state.ChainID) config.Set("chain_id", state.ChainID)


+ 24
- 0
proxy/multi_app_conn.go View File

@ -52,6 +52,16 @@ func Handshake(config cfg.Config, state State, blockStore BlockStore) {
//--------- //---------
type AppConns interface {
Mempool() AppConnMempool
Consensus() AppConnConsensus
Query() AppConnQuery
}
func NewAppConns(config cfg.Config, state State, blockStore BlockStore) AppConns {
return NewMultiAppConn(config, state, blockStore)
}
// a multiAppConn is made of a few appConns (mempool, consensus) // a multiAppConn is made of a few appConns (mempool, consensus)
// and manages their underlying tmsp clients, ensuring they reboot together // and manages their underlying tmsp clients, ensuring they reboot together
type multiAppConn struct { type multiAppConn struct {
@ -64,6 +74,7 @@ type multiAppConn struct {
mempoolConn *appConnMempool mempoolConn *appConnMempool
consensusConn *appConnConsensus consensusConn *appConnConsensus
queryConn *appConnQuery
} }
// Make all necessary tmsp connections to the application // Make all necessary tmsp connections to the application
@ -88,18 +99,31 @@ func (app *multiAppConn) Consensus() AppConnConsensus {
return app.consensusConn return app.consensusConn
} }
func (app *multiAppConn) Query() AppConnQuery {
return app.queryConn
}
func (app *multiAppConn) OnStart() error { func (app *multiAppConn) OnStart() error {
app.QuitService.OnStart() app.QuitService.OnStart()
addr := app.config.GetString("proxy_app") addr := app.config.GetString("proxy_app")
transport := app.config.GetString("tmsp") transport := app.config.GetString("tmsp")
// query connection
querycli, err := NewTMSPClient(addr, transport)
if err != nil {
return err
}
app.queryConn = NewAppConnMempool(querycli)
// mempool connection
memcli, err := NewTMSPClient(addr, transport) memcli, err := NewTMSPClient(addr, transport)
if err != nil { if err != nil {
return err return err
} }
app.mempoolConn = NewAppConnMempool(memcli) app.mempoolConn = NewAppConnMempool(memcli)
// consensus connection
concli, err := NewTMSPClient(addr, transport) concli, err := NewTMSPClient(addr, transport)
if err != nil { if err != nil {
return err return err


Loading…
Cancel
Save