diff --git a/rpc/chain/client.go b/rpc/chain/client.go index 5718eb52e..0e490d501 100644 --- a/rpc/chain/client.go +++ b/rpc/chain/client.go @@ -34,10 +34,9 @@ type ClientWithFallback struct { WalletNotifier func(chainId uint64, message string) - IsConnected bool - consecutiveFailureCount int - IsConnectedLock sync.RWMutex - LastCheckedAt int64 + IsConnected bool + IsConnectedLock sync.RWMutex + LastCheckedAt int64 } var vmErrors = []error{ @@ -71,14 +70,13 @@ func NewSimpleClient(main *rpc.Client, chainID uint64) *ClientWithFallback { }) return &ClientWithFallback{ - ChainID: chainID, - main: ethclient.NewClient(main), - fallback: nil, - mainRPC: main, - fallbackRPC: nil, - IsConnected: true, - consecutiveFailureCount: 0, - LastCheckedAt: time.Now().Unix(), + ChainID: chainID, + main: ethclient.NewClient(main), + fallback: nil, + mainRPC: main, + fallbackRPC: nil, + IsConnected: true, + 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 { diff --git a/services/wallet/history/service_test.go b/services/wallet/history/service_test.go index 13dfa2468..c3e9bcd26 100644 --- a/services/wallet/history/service_test.go +++ b/services/wallet/history/service_test.go @@ -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()) } } diff --git a/services/wallet/market/market.go b/services/wallet/market/market.go index af669fbbe..956c4df92 100644 --- a/services/wallet/market/market.go +++ b/services/wallet/market/market.go @@ -5,6 +5,7 @@ import ( "time" "github.com/afex/hystrix-go/hystrix" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" diff --git a/services/wallet/market/market_test.go b/services/wallet/market/market_test.go index 75906c149..2f725f30c 100644 --- a/services/wallet/market/market_test.go +++ b/services/wallet/market/market_test.go @@ -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) { diff --git a/services/wallet/thirdparty/coingecko/client.go b/services/wallet/thirdparty/coingecko/client.go index 57d50c940..0d7aa6f01 100644 --- a/services/wallet/thirdparty/coingecko/client.go +++ b/services/wallet/thirdparty/coingecko/client.go @@ -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 {