diff --git a/rpc/client.go b/rpc/client.go index 109b87407..e88387f09 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -175,7 +175,9 @@ func NewClient(client *gethrpc.Client, upstreamChainID uint64, upstream params.U ethClients := []ethclient.RPSLimitedEthClientInterface{ ethclient.NewRPSLimitedEthClient(upstreamClient, limiter, rpcName), } - c.upstream = chain.NewClient(ethClients, upstreamChainID) + providersHealthManager := healthManager.NewProvidersHealthManager(upstreamChainID) + c.BlockchainHealthManager.RegisterProvidersHealthManager(upstreamChainID, providersHealthManager) + c.upstream = chain.NewClient(ethClients, upstreamChainID, providersHealthManager) } c.router = newRouter(c.upstreamEnabled) @@ -195,7 +197,7 @@ func (c *Client) SetWalletNotifier(notifier func(chainID uint64, message string) c.walletNotifier = notifier } -func (c *Client) SubscribeHealthStatus() chan health_manager.BlockchainHealthStatus { +func (c *Client) SubscribeHealthStatus() chan healthManager.BlockchainHealthStatus { return c.BlockchainHealthManager.Subscribe() } @@ -396,7 +398,9 @@ func (c *Client) UpdateUpstreamURL(url string) error { ethClients := []ethclient.RPSLimitedEthClientInterface{ ethclient.NewRPSLimitedEthClient(rpcClient, rpsLimiter, hostPortUpstream), } - c.upstream = chain.NewClient(ethClients, c.UpstreamChainID) + providersHealthManager := healthManager.NewProvidersHealthManager(c.UpstreamChainID) + c.BlockchainHealthManager.RegisterProvidersHealthManager(c.UpstreamChainID, providersHealthManager) + c.upstream = chain.NewClient(ethClients, c.UpstreamChainID, providersHealthManager) c.upstreamURL = url c.Unlock() diff --git a/rpc/health-manager/network_errors.go b/rpc/health-manager/network_errors.go index 9d663e2a6..315398314 100644 --- a/rpc/health-manager/network_errors.go +++ b/rpc/health-manager/network_errors.go @@ -134,10 +134,16 @@ func IsNotFoundError(err error) bool { } func IsHTTPError(err error) (bool, int) { - var httpErr *rpc.HTTPError + var httpErrPtr *rpc.HTTPError + if errors.As(err, &httpErrPtr) { + return true, httpErrPtr.StatusCode + } + + var httpErr rpc.HTTPError if errors.As(err, &httpErr) { return true, httpErr.StatusCode } + return false, 0 } diff --git a/rpc/health-manager/providers_health_manager.go b/rpc/health-manager/providers_health_manager.go index dbb8decc1..b4f129f72 100644 --- a/rpc/health-manager/providers_health_manager.go +++ b/rpc/health-manager/providers_health_manager.go @@ -204,7 +204,7 @@ func (p *ProvidersHealthManager) updateChainStatus() { func isNonCriticalError(errorType ProviderErrorType) bool { switch errorType { - case ErrorTypeNone, ErrorTypeRPSLimit, ErrorTypeVMError, ErrorTypeContextCanceled, ErrorTypeNotFound: + case ErrorTypeNone, ErrorTypeNotFound, ErrorTypeVMError, ErrorTypeRPSLimit, ErrorTypeContextCanceled, ErrorTypeContentTooLarge, ErrorTypeMethodNotFound: return true default: return false diff --git a/services/wallet/service.go b/services/wallet/service.go index ce11d2e12..401adfd6c 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -282,24 +282,24 @@ func (s *Service) handleBlockchainHealthStatus(blockchainHealthCh chan healthMan Message: string(jsonData), At: time.Now().Unix(), }) - - // send old event - // TODO: remove and use the new event only - blockchainStatusOld := make(map[uint64]string) - for chainID, chainStatus := range blockchainStatus.Status.Chains { - statusStr := string(chainStatus.Status) - blockchainStatusOld[chainID] = statusStr - } - encodedMessage, err := json.Marshal(blockchainStatus) - if err != nil { - continue - } - s.feed.Send(walletevent.Event{ - Type: EventBlockchainStatusChanged, - Accounts: []common.Address{}, - Message: string(encodedMessage), - At: time.Now().Unix(), - }) + // + //// send old event + //// TODO: remove and use the new event only + //blockchainStatusOld := make(map[uint64]string) + //for chainID, chainStatus := range blockchainStatus.Status.Chains { + // statusStr := string(chainStatus.Status) + // blockchainStatusOld[chainID] = statusStr + //} + //encodedMessage, err := json.Marshal(blockchainStatus) + //if err != nil { + // continue + //} + //s.feed.Send(walletevent.Event{ + // Type: EventBlockchainStatusChanged, + // Accounts: []common.Address{}, + // Message: string(encodedMessage), + // At: time.Now().Unix(), + //}) } }