Skip to content

Commit

Permalink
add attempt for get tonstakers price
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhar-petukhov committed Nov 6, 2023
1 parent 9e53095 commit eca4db5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions pkg/rates/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"math"
"net/http"
"strconv"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/labstack/gommon/log"
"github.com/tonkeeper/opentonapi/pkg/references"
"github.com/tonkeeper/tongo"
Expand Down Expand Up @@ -67,17 +68,14 @@ func (m *Mock) GetCurrentRates() (map[string]float64, error) {
pools[address] = price
}
}
tonstakersJetton, tonstakersPrice, err := getTonstakersPrice(references.TonstakersAccountPool)
if err == nil {
pools[tonstakersJetton] = tonstakersPrice
} else {
log.Errorf("tonstakers price: %v", err)
errorsCounter.WithLabelValues("tonstakers").Inc()
time.Sleep(time.Second * 5)
tonstakersJetton, tonstakersPrice, err = getTonstakersPrice(references.TonstakersAccountPool)
if err == nil {

for attempt := 0; attempt < 3; attempt++ {
if tonstakersJetton, tonstakersPrice, err := getTonstakersPrice(references.TonstakersAccountPool); err == nil {
pools[tonstakersJetton] = tonstakersPrice
break
}
errorsCounter.WithLabelValues("tonstakers").Inc()
time.Sleep(time.Second * 3)
}

// All data is displayed to the ratio to TON
Expand Down

0 comments on commit eca4db5

Please sign in to comment.