core: enable trade store's trade pruning in NewTradeCollector

This commit is contained in:
c9s 2023-12-12 18:21:22 +08:00
parent 97c39921bd
commit 685f332495
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -34,12 +34,15 @@ type TradeCollector struct {
}
func NewTradeCollector(symbol string, position *types.Position, orderStore *OrderStore) *TradeCollector {
tradeStore := NewTradeStore()
tradeStore.EnablePrune = true
return &TradeCollector{
Symbol: symbol,
orderSig: sigchan.New(1),
tradeC: make(chan types.Trade, 100),
tradeStore: NewTradeStore(),
tradeStore: tradeStore,
doneTrades: make(map[types.TradeKey]struct{}),
position: position,
orderStore: orderStore,
@ -88,7 +91,9 @@ func (c *TradeCollector) Emit() {
c.orderSig.Emit()
}
func (c *TradeCollector) Recover(ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, from time.Time) error {
func (c *TradeCollector) Recover(
ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, from time.Time,
) error {
logrus.Debugf("recovering %s trades...", symbol)
trades, err := ex.QueryTrades(ctx, symbol, &types.TradeQueryOptions{