Skip to content

Commit 48d7472

Browse files
committed
add wait time to velar liquidity scraper.
1 parent 586e3eb commit 48d7472

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

cmd/liquidityScraper/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/liquidityScraper
33
go 1.22
44

55
require (
6-
github.com/diadata-org/diadata v1.4.560
6+
github.com/diadata-org/diadata v1.4.565
77
github.com/sirupsen/logrus v1.9.3
88
)
99

pkg/dia/scraper/liquidity-scrapers/VelarScraper.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/hex"
66
"math/big"
7+
"strconv"
78
"strings"
89
"time"
910

@@ -16,16 +17,17 @@ import (
1617
)
1718

1819
type VelarLiquidityScraper struct {
19-
logger *logrus.Entry
20-
api *stackshelper.StacksClient
21-
velarClient *velarhelper.VelarClient
22-
poolChannel chan dia.Pool
23-
doneChannel chan bool
24-
blockchain string
25-
exchangeName string
26-
relDB *models.RelDB
27-
datastore *models.DB
28-
handlerType string
20+
logger *logrus.Entry
21+
api *stackshelper.StacksClient
22+
velarClient *velarhelper.VelarClient
23+
poolChannel chan dia.Pool
24+
doneChannel chan bool
25+
blockchain string
26+
exchangeName string
27+
sleepTimeMilliseconds int
28+
relDB *models.RelDB
29+
datastore *models.DB
30+
handlerType string
2931
}
3032

3133
// NewVelarLiquidityScraper returns a new VelarLiquidityScraper initialized with default values.
@@ -54,16 +56,21 @@ func NewVelarLiquidityScraper(exchange dia.Exchange, relDB *models.RelDB, datast
5456
isDebug,
5557
)
5658

59+
sleepTime, err := strconv.Atoi(utils.Getenv("SLEEP_TIME_MILLISECONDS", "1000"))
60+
if err != nil {
61+
log.Error("parse SLEEP_TIME_MILLISECONDS: ", err)
62+
}
5763
s := &VelarLiquidityScraper{
58-
poolChannel: make(chan dia.Pool),
59-
doneChannel: make(chan bool),
60-
exchangeName: exchange.Name,
61-
blockchain: exchange.BlockChain.Name,
62-
api: stacksClient,
63-
velarClient: velarClient,
64-
relDB: relDB,
65-
datastore: datastore,
66-
handlerType: "liquidity",
64+
poolChannel: make(chan dia.Pool),
65+
doneChannel: make(chan bool),
66+
exchangeName: exchange.Name,
67+
blockchain: exchange.BlockChain.Name,
68+
sleepTimeMilliseconds: sleepTime,
69+
api: stacksClient,
70+
velarClient: velarClient,
71+
relDB: relDB,
72+
datastore: datastore,
73+
handlerType: "liquidity",
6774
}
6875

6976
s.logger = logrus.
@@ -85,6 +92,8 @@ func (s *VelarLiquidityScraper) fetchPools() {
8592
}
8693

8794
for _, t := range tickers {
95+
time.Sleep(time.Duration(s.sleepTimeMilliseconds) * time.Millisecond)
96+
8897
balances, err := s.fetchPoolBalances(t.PoolID)
8998
if err != nil {
9099
s.logger.WithError(err).Error("failed to fetch velar pool balances")

0 commit comments

Comments
 (0)