mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Enable superfluous ws.port flag to fix some Hive RPC tests (#8909)
### Context **Websocket port flag** Hive tests for RPC suite depend on the (geth) default 8546 port. So, opening one more listener for this additional port if `ws.port` was specified. This flag isn't used in Erigon, as it shares port with http listener. Normally, one may not specify and it offers no other benefit.
This commit is contained in:
parent
f3822b17d4
commit
5987d4ef72
@ -630,6 +630,27 @@ func startRegularRpcServer(ctx context.Context, cfg *httpcfg.HttpCfg, rpcAPI []r
|
||||
return err
|
||||
}
|
||||
|
||||
// Separate Websocket handler if websocket port flag specified
|
||||
if cfg.WebsocketEnabled && cfg.WebsocketPort != cfg.HttpPort {
|
||||
wsEndpoint := fmt.Sprintf("tcp://%s:%d", cfg.HttpListenAddress, cfg.WebsocketPort)
|
||||
wsApiHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if isWebsocket(r) {
|
||||
wsHandler.ServeHTTP(w, r)
|
||||
}
|
||||
})
|
||||
wsListener, wsAddr, err := node.StartHTTPEndpoint(wsEndpoint, &node.HttpEndpointConfig{Timeouts: cfg.HTTPTimeouts}, wsApiHandler)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not start separate Websocket RPC api at port %d: %w", cfg.WebsocketPort, err)
|
||||
}
|
||||
info = append(info, "websocket.url", wsAddr)
|
||||
defer func() {
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
_ = wsListener.Shutdown(shutdownCtx)
|
||||
logger.Info("HTTP endpoint closed", "url", wsAddr)
|
||||
}()
|
||||
}
|
||||
|
||||
if cfg.HttpServerEnabled {
|
||||
httpEndpoint := fmt.Sprintf("tcp://%s:%d", cfg.HttpListenAddress, cfg.HttpPort)
|
||||
if cfg.HttpURL != "" {
|
||||
|
@ -43,6 +43,7 @@ type HttpCfg struct {
|
||||
API []string
|
||||
Gascap uint64
|
||||
MaxTraces uint64
|
||||
WebsocketPort int
|
||||
WebsocketEnabled bool
|
||||
WebsocketCompression bool
|
||||
RpcAllowListFilePath string
|
||||
|
@ -63,6 +63,7 @@ var DefaultFlags = []cli.Flag{
|
||||
&utils.HTTPVirtualHostsFlag,
|
||||
&utils.AuthRpcVirtualHostsFlag,
|
||||
&utils.HTTPApiFlag,
|
||||
&utils.WSPortFlag,
|
||||
&utils.WSEnabledFlag,
|
||||
&utils.WsCompressionFlag,
|
||||
&utils.HTTPTraceFlag,
|
||||
|
@ -386,8 +386,8 @@ func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *nodecfg.Config, logger log.Logg
|
||||
WriteTimeout: ctx.Duration(AuthRpcWriteTimeoutFlag.Name),
|
||||
IdleTimeout: ctx.Duration(HTTPIdleTimeoutFlag.Name),
|
||||
},
|
||||
EvmCallTimeout: ctx.Duration(EvmCallTimeoutFlag.Name),
|
||||
|
||||
EvmCallTimeout: ctx.Duration(EvmCallTimeoutFlag.Name),
|
||||
WebsocketPort: ctx.Int(utils.WSPortFlag.Name),
|
||||
WebsocketEnabled: ctx.IsSet(utils.WSEnabledFlag.Name),
|
||||
RpcBatchConcurrency: ctx.Uint(utils.RpcBatchConcurrencyFlag.Name),
|
||||
RpcStreamingDisable: ctx.Bool(utils.RpcStreamingDisableFlag.Name),
|
||||
|
Loading…
Reference in New Issue
Block a user