Skip to content

Commit

Permalink
Merge pull request #56 from KyberNetwork/Feature/Accelerate_backfill_…
Browse files Browse the repository at this point in the history
…TradeLogs_usd_value

Feature/Accelerate_backfill_TradeLogs_usd_value
  • Loading branch information
Haiss2 authored Jul 12, 2024
2 parents a45d5e5 + fc1cadc commit e357221
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/pricefiller/price_fillter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ const (
NetworkETHChanID = 1
NetworkETH = "ETH"
updateAllCoinInfoInterval = time.Hour
backfillTradeLogsPriceInterval = time.Hour
backfillTradeLogsPriceInterval = 30 * time.Second
backfillTradeLogsLimit = 60
addressETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
coinUSDT = "USDT"
invalidSymbolErrString = "<APIError> code=-1121, msg=Invalid symbol."
)

var (
Expand Down Expand Up @@ -136,7 +138,7 @@ func (p *PriceFiller) runBackFillTradelogPriceRoutine() {
for range ticker.C {
tradeLogs, err := p.s.Get(storage.TradeLogsQuery{
State: string(storage.TradeLogStateNew),
Limit: 100,
Limit: backfillTradeLogsLimit,
})
if err != nil {
p.l.Errorw("Failed to get tradeLogs", "err", err)
Expand All @@ -157,8 +159,10 @@ func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.Trade
makerPrice, makerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.MakerToken),
tradeLog.MakerTokenAmount, int64(tradeLog.Timestamp))
if err != nil {
p.l.Errorw("Failed to getPriceAndAmountUsd for maker", "err", err)
return tradeLog, err
if err.Error() != invalidSymbolErrString {
p.l.Errorw("Failed to getPriceAndAmountUsd for maker", "err", err)
return tradeLog, err
}
}

tradeLog.MakerTokenPrice = makerPrice
Expand All @@ -167,8 +171,10 @@ func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.Trade
takerPrice, takerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.TakerToken),
tradeLog.TakerTokenAmount, int64(tradeLog.Timestamp))
if err != nil {
p.l.Errorw("Failed to getPriceAndAmountUsd for taker", "err", err)
return tradeLog, err
if err.Error() != invalidSymbolErrString {
p.l.Errorw("Failed to getPriceAndAmountUsd for taker", "err", err)
return tradeLog, err
}
}

tradeLog.TakerTokenPrice = takerPrice
Expand Down

0 comments on commit e357221

Please sign in to comment.