chore_: send health events

This commit is contained in:
Andrey Bocharnikov 2024-09-24 17:26:03 +04:00
parent 0a72e3f7e4
commit b2011773fc
3 changed files with 19 additions and 2 deletions

View File

@ -193,6 +193,10 @@ func (c *Client) SetWalletNotifier(notifier func(chainID uint64, message string)
c.walletNotifier = notifier
}
func (c *Client) SubscribeHealthStatus() chan health_manager.BlockchainHealthStatus {
return c.blockchainHealthManager.Subscribe()
}
func extractHostFromURL(inputURL string) (string, error) {
parsedURL, err := url.Parse(inputURL)
if err != nil {

View File

@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/circuitbreaker"
"github.com/status-im/status-go/services/network_utils"
"github.com/status-im/status-go/services/wallet/thirdparty"
"github.com/status-im/status-go/services/wallet/walletevent"
)
@ -99,7 +98,7 @@ func (pm *Manager) makeCall(providers []thirdparty.MarketDataProvider, f func(pr
}
result := pm.circuitbreaker.Execute(cmd)
skipNotification := network_utils.IsConnectionError(result.Error())
skipNotification := health_manager.IsConnectionError(result.Error())
pm.setIsConnected(result.Error() == nil, skipNotification)
if result.Error() != nil {

View File

@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
health_manager "github.com/status-im/status-go/rpc/health-manager"
"sync"
"time"
@ -44,6 +45,7 @@ import (
const (
EventBlockchainStatusChanged walletevent.EventType = "wallet-blockchain-status-changed"
EventBlockchainHealthChanged walletevent.EventType = "wallet-blockchain-health-changed"
)
// NewService initializes service instance.
@ -261,9 +263,21 @@ func (s *Service) Start() error {
s.history.Start()
s.collectibles.Start()
s.started = true
blockchainHealthCh := s.rpcClient.SubscribeHealthStatus()
go s.handleBlockchainHealthStatus(blockchainHealthCh)
return err
}
func (s *Service) handleBlockchainHealthStatus(blockchainHealthCh chan health_manager.BlockchainHealthStatus) {
for _ := range blockchainHealthCh {
s.feed.Send(walletevent.Event{
Type: walletevent.EventBlockchainHealthChanged,
Message: "todo",
At: time.Now().Unix(),
})
}
}
// Set external Collectibles community info provider
func (s *Service) SetWalletCommunityInfoProvider(provider thirdparty.CommunityInfoProvider) {
s.communityManager.SetCommunityInfoProvider(provider)