fix serve command for ipld graphql server

This commit is contained in:
ramil 2021-04-16 16:56:02 +03:00
parent 75debec01a
commit 31cbaec567
2 changed files with 13 additions and 8 deletions

View File

@ -164,15 +164,19 @@ func startIpldGraphQL(settings *s.Config) error {
return err return err
} }
ethClients, err := parseRpcAddresses(viper.GetString("ethereum.httpPath")) ethClients, err := parseRpcAddresses(settings.EthHttpEndpoint)
if err != nil { if err != nil {
return err return err
} }
tracingClients, err := parseRpcAddresses(viper.GetString("tracing.httpPath")) var tracingClients []*rpc.Client
tracingEndpoint := viper.GetString("tracing.httpPath")
if tracingEndpoint != "" {
tracingClients, err = parseRpcAddresses(tracingEndpoint)
if err != nil { if err != nil {
return err return err
} }
}
router, err := mux.NewServeMux(&mux.Options{ router, err := mux.NewServeMux(&mux.Options{
BasePath: "/", BasePath: "/",
@ -190,9 +194,7 @@ func startIpldGraphQL(settings *s.Config) error {
return err return err
} }
if err := http.ListenAndServe(settings.IpldGraphqlEndpoint, router); err != nil { go http.ListenAndServe(settings.IpldGraphqlEndpoint, router)
logWithCommand.Fatal(err)
}
} else { } else {
logWithCommand.Info("IPLD GraphQL server is disabled") logWithCommand.Info("IPLD GraphQL server is disabled")
} }

View File

@ -79,6 +79,7 @@ type Config struct {
ChainConfig *params.ChainConfig ChainConfig *params.ChainConfig
DefaultSender *common.Address DefaultSender *common.Address
RPCGasCap *big.Int RPCGasCap *big.Int
EthHttpEndpoint string
Client *rpc.Client Client *rpc.Client
SupportStateDiff bool SupportStateDiff bool
} }
@ -97,12 +98,14 @@ func NewConfig() (*Config, error) {
c.DBConfig.Init() c.DBConfig.Init()
ethHTTP := viper.GetString("ethereum.httpPath") ethHTTP := viper.GetString("ethereum.httpPath")
nodeInfo, cli, err := shared.GetEthNodeAndClient(fmt.Sprintf("http://%s", ethHTTP)) ethHTTPEndpoint := fmt.Sprintf("http://%s", ethHTTP)
nodeInfo, cli, err := shared.GetEthNodeAndClient(ethHTTPEndpoint)
if err != nil { if err != nil {
return nil, err return nil, err
} }
c.Client = cli c.Client = cli
c.SupportStateDiff = viper.GetBool("ethereum.supportsStateDiff") c.SupportStateDiff = viper.GetBool("ethereum.supportsStateDiff")
c.EthHttpEndpoint = ethHTTPEndpoint
// websocket server // websocket server
wsEnabled := viper.GetBool("eth.server.ws") wsEnabled := viper.GetBool("eth.server.ws")