feat: remove consecutive

This commit is contained in:
Anthony Laibe 2023-03-31 11:20:02 +02:00 committed by Anthony Laibe
parent cd6d22d1c1
commit c84d6fcc35
5 changed files with 17 additions and 18 deletions

View File

@ -35,7 +35,6 @@ type ClientWithFallback struct {
WalletNotifier func(chainId uint64, message string)
IsConnected bool
consecutiveFailureCount int
IsConnectedLock sync.RWMutex
LastCheckedAt int64
}
@ -77,7 +76,6 @@ func NewSimpleClient(main *rpc.Client, chainID uint64) *ClientWithFallback {
mainRPC: main,
fallbackRPC: nil,
IsConnected: true,
consecutiveFailureCount: 0,
LastCheckedAt: time.Now().Unix(),
}
}
@ -129,7 +127,6 @@ func (c *ClientWithFallback) SetIsConnected(value bool) {
defer c.IsConnectedLock.Unlock()
c.LastCheckedAt = time.Now().Unix()
if !value {
c.consecutiveFailureCount += 1
if c.IsConnected {
if c.WalletNotifier != nil {
c.WalletNotifier(c.ChainID, "down")
@ -138,8 +135,6 @@ func (c *ClientWithFallback) SetIsConnected(value bool) {
}
} else {
c.consecutiveFailureCount = 0
if !c.IsConnected {
c.IsConnected = true
if c.WalletNotifier != nil {

View File

@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/event"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/golang/mock/gomock"
@ -41,7 +42,7 @@ func setupDummyServiceNoDependencies(t *testing.T) (service *Service, closeFn fu
rpcClient, err := statusRPC.NewClient(client, 1, upstreamConfig, nil, db)
require.NoError(t, err)
return NewService(db, nil, rpcClient, nil, market.NewManager(cryptoCompare, cryptoCompare)), func() {
return NewService(db, nil, rpcClient, nil, market.NewManager(cryptoCompare, cryptoCompare, &event.Feed{})), func() {
require.NoError(t, db.Close())
}
}

View File

@ -5,6 +5,7 @@ import (
"time"
"github.com/afex/hystrix-go/hystrix"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"

View File

@ -4,6 +4,8 @@ import (
"errors"
"testing"
"github.com/ethereum/go-ethereum/event"
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/services/wallet/thirdparty"
@ -46,7 +48,7 @@ func (mpp *MockPriceProvider) FetchPrices(symbols []string, currencies []string)
}
func setupTestPrice(t *testing.T, provider thirdparty.MarketDataProvider) *Manager {
return NewManager(provider, provider)
return NewManager(provider, provider, &event.Feed{})
}
func TestPrice(t *testing.T) {

View File

@ -224,7 +224,7 @@ func (c *Client) FetchTokenMarketValues(symbols []string, currency string) (map[
if err != nil {
return nil, err
}
url := fmt.Sprintf("%scoins/markets?ids=%s&vs_currency=%s&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h%2C24h", baseURL, strings.Join(ids, ","), currency)
url := fmt.Sprintf("%scoins/markets?ids=%s&vs_currency=%s&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=%s", baseURL, strings.Join(ids, ","), currency, "1h%2C24h")
resp, err := c.DoQuery(url)
if err != nil {