Skip to content

Commit

Permalink
add zenlink dex scraper main.
Browse files Browse the repository at this point in the history
  • Loading branch information
jppade committed Aug 2, 2023
1 parent faccbc2 commit 651ac2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/exchange-scrapers/generic-collector/zenlink/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/exchange-scrapers/generic-collector/zenlin
go 1.17

require (
github.com/diadata-org/diadata v1.4.251
github.com/diadata-org/diadata v1.4.318
github.com/segmentio/kafka-go v0.4.35
github.com/sirupsen/logrus v1.8.1
)
Expand Down
19 changes: 7 additions & 12 deletions cmd/exchange-scrapers/generic-collector/zenlink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var (
exchange = dia.ZenlinkswapExchange
exchange = flag.String("exchange", "", "which exchange")
// mode==current: default mode. Trades are forwarded to TBS and FBS.
// mode==storeTrades: trades are not forwarded to TBS and FBS and stored as raw trades in influx.
// mode==estimation: trades are forwarded to tradesEstimationService, i.e. same as storeTrades mode
Expand All @@ -36,7 +36,7 @@ func init() {
// main manages all PairScrapers and handles incoming trade information
func main() {

log.Infof("start collector for %s in %s mode...", exchange, *mode)
log.Infof("start collector for %s in %s mode...", *exchange, *mode)

relDB, err := models.NewRelDataStore()
if err != nil {
Expand All @@ -51,23 +51,18 @@ func main() {
// Fetch exchange pairs from database or json file in config folder.
var pairsExchange []dia.ExchangePair
if !*pairsfile {
pairsExchange, err = relDB.GetExchangePairSymbols(exchange)
pairsExchange, err = relDB.GetExchangePairSymbols(*exchange)
if err != nil {
log.Fatal("fetch pairs from database: ", err)
}
} else {
log.Error("error on GetExchangePairSymbols", err)
cc := configCollectors.NewConfigCollectors(exchange, ".json")
cc := configCollectors.NewConfigCollectors(*exchange, ".json")
pairsExchange = cc.AllPairs()
}
log.Info("available exchangePairs:", len(pairsExchange))

exchangeConfig, err := relDB.GetExchange(dia.ZenlinkswapExchange)
if err != nil {
log.Warning("no config for exchange ", err)
}

diaExchange := dia.Exchange{Name: exchange, Centralized: true, WatchdogDelay: exchangeConfig.WatchdogDelay}
diaExchange := scrapers.Exchanges[*exchange]
es := scrapers.NewZenlinkScraper(diaExchange, true)

// Set up kafka writers for various modes.
Expand Down Expand Up @@ -98,7 +93,7 @@ func main() {

wg := sync.WaitGroup{}

if scrapers.Exchanges[exchange].Centralized {
if scrapers.Exchanges[*exchange].Centralized {

// Scrape pairs for CEX scrapers.
for _, configPair := range pairsExchange {
Expand All @@ -121,7 +116,7 @@ func main() {
defer wg.Wait()

}
go handleTrades(es.Channel(), &wg, w, wTest, wReplica, ds, exchange, *mode)
go handleTrades(es.Channel(), &wg, w, wTest, wReplica, ds, *exchange, *mode)
}

func handleTrades(c chan *dia.Trade, wg *sync.WaitGroup, w *kafka.Writer, wTest *kafka.Writer, wReplica *kafka.Writer, ds *models.DB, exchange string, mode string) {
Expand Down

0 comments on commit 651ac2a

Please sign in to comment.