Browse Source

lite support maxOpenConnections (#2413)

bucky/upgrades
bradyjoestar 6 years ago
committed by Ethan Buchman
parent
commit
5b120d788a
2 changed files with 9 additions and 8 deletions
  1. +7
    -5
      cmd/tendermint/commands/lite.go
  2. +2
    -3
      lite/proxy/proxy.go

+ 7
- 5
cmd/tendermint/commands/lite.go View File

@ -26,10 +26,11 @@ just with added trust and running locally.`,
}
var (
listenAddr string
nodeAddr string
chainID string
home string
listenAddr string
nodeAddr string
chainID string
home string
maxOpenConnections int
cacheSize int
)
@ -38,6 +39,7 @@ func init() {
LiteCmd.Flags().StringVar(&nodeAddr, "node", "tcp://localhost:26657", "Connect to a Tendermint node at this address")
LiteCmd.Flags().StringVar(&chainID, "chain-id", "tendermint", "Specify the Tendermint chain ID")
LiteCmd.Flags().StringVar(&home, "home-dir", ".tendermint-lite", "Specify the home directory")
LiteCmd.Flags().IntVar(&maxOpenConnections,"max-open-connections",900,"Maximum number of simultaneous connections (including WebSocket).")
LiteCmd.Flags().IntVar(&cacheSize, "cache-size", 10, "Specify the memory trust store cache size")
}
@ -79,7 +81,7 @@ func runProxy(cmd *cobra.Command, args []string) error {
sc := proxy.SecureClient(node, cert)
logger.Info("Starting proxy...")
err = proxy.StartProxy(sc, listenAddr, logger)
err = proxy.StartProxy(sc, listenAddr, logger, maxOpenConnections)
if err != nil {
return cmn.ErrorWrap(err, "starting proxy")
}


+ 2
- 3
lite/proxy/proxy.go View File

@ -19,7 +19,7 @@ const (
// StartProxy will start the websocket manager on the client,
// set up the rpc routes to proxy via the given client,
// and start up an http/rpc server on the location given by bind (eg. :1234)
func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger) error {
func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger, maxOpenConnections int) error {
err := c.Start()
if err != nil {
return err
@ -38,8 +38,7 @@ func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger) error
core.SetLogger(logger)
mux.HandleFunc(wsEndpoint, wm.WebsocketHandler)
// TODO: limit max number of open connections rpc.Config{MaxOpenConnections: X}
_, err = rpc.StartHTTPServer(listenAddr, mux, logger, rpc.Config{})
_, err = rpc.StartHTTPServer(listenAddr, mux, logger, rpc.Config{MaxOpenConnections: maxOpenConnections})
return err
}


Loading…
Cancel
Save