From 2a254f85a54961c9c119777c2787dbcc7f838017 Mon Sep 17 00:00:00 2001 From: Haiss2 Date: Fri, 12 Jul 2024 17:30:36 +0700 Subject: [PATCH 1/3] Feature/Accelerate_backfill_TradeLogs_usd_value --- pkg/pricefiller/price_fillter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/pricefiller/price_fillter.go b/pkg/pricefiller/price_fillter.go index 4215da2..12ca51b 100644 --- a/pkg/pricefiller/price_fillter.go +++ b/pkg/pricefiller/price_fillter.go @@ -17,7 +17,8 @@ const ( NetworkETHChanID = 1 NetworkETH = "ETH" updateAllCoinInfoInterval = time.Hour - backfillTradeLogsPriceInterval = time.Hour + backfillTradeLogsPriceInterval = time.Minute + backfillTradeLogsLimit = 60 addressETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" coinUSDT = "USDT" ) @@ -136,7 +137,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) From b6d29d781153a49edfed7a4945a71a28dd6baa04 Mon Sep 17 00:00:00 2001 From: Haiss2 Date: Fri, 12 Jul 2024 17:31:42 +0700 Subject: [PATCH 2/3] more acceleration --- pkg/pricefiller/price_fillter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pricefiller/price_fillter.go b/pkg/pricefiller/price_fillter.go index 12ca51b..ed28e41 100644 --- a/pkg/pricefiller/price_fillter.go +++ b/pkg/pricefiller/price_fillter.go @@ -17,7 +17,7 @@ const ( NetworkETHChanID = 1 NetworkETH = "ETH" updateAllCoinInfoInterval = time.Hour - backfillTradeLogsPriceInterval = time.Minute + backfillTradeLogsPriceInterval = 30 * time.Second backfillTradeLogsLimit = 60 addressETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" coinUSDT = "USDT" From fc1cadc808836695b756c77a827d29c8b47f9acd Mon Sep 17 00:00:00 2001 From: Haiss2 Date: Fri, 12 Jul 2024 17:47:17 +0700 Subject: [PATCH 3/3] Ignore Invalid symbol error --- pkg/pricefiller/price_fillter.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/pricefiller/price_fillter.go b/pkg/pricefiller/price_fillter.go index ed28e41..71e5ca8 100644 --- a/pkg/pricefiller/price_fillter.go +++ b/pkg/pricefiller/price_fillter.go @@ -21,6 +21,7 @@ const ( backfillTradeLogsLimit = 60 addressETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" coinUSDT = "USDT" + invalidSymbolErrString = " code=-1121, msg=Invalid symbol." ) var ( @@ -158,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 @@ -168,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