From a17e2777a7ec01cb9c451eaa0daea8ccca03623f Mon Sep 17 00:00:00 2001 From: wwestgarth Date: Wed, 10 Jul 2024 12:41:19 +0100 Subject: [PATCH] fix: demote order-spam logs to debug and avoid data-node warning log --- core/collateral/engine.go | 11 ++++++++--- datanode/sqlsubscribers/order.go | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/collateral/engine.go b/core/collateral/engine.go index 10e999436ad..39640306389 100644 --- a/core/collateral/engine.go +++ b/core/collateral/engine.go @@ -211,7 +211,10 @@ func (e *Engine) CheckOrderSpamAllMarkets(party string) error { func (e *Engine) CheckOrderSpam(party, market string, assets []string) error { e.cacheLock.RLock() defer e.cacheLock.RUnlock() - e.log.Info("CheckOrderSpam", logging.String("party", party), logging.String("market", market), logging.Strings("assets", assets)) + + if e.log.IsDebug() { + e.log.Debug("CheckOrderSpam", logging.String("party", party), logging.String("market", market), logging.Strings("assets", assets)) + } if assetBalances, ok := e.partyAssetCache[party]; !ok { return fmt.Errorf("party " + party + " is not eligible to submit order transactions in market " + market + " (no general account in no asset)") } else { @@ -225,8 +228,10 @@ func (e *Engine) CheckOrderSpam(party, market string, assets []string) error { } } if !found { - for ast, balance := range e.partyAssetCache[party] { - e.log.Info("party asset cache", logging.String("party", party), logging.String("asset", ast), logging.String("balance", balance.String())) + if e.log.IsDebug() { + for ast, balance := range e.partyAssetCache[party] { + e.log.Debug("party asset cache", logging.String("party", party), logging.String("asset", ast), logging.String("balance", balance.String())) + } } return fmt.Errorf("party " + party + " is not eligible to submit order transactions in market " + market + " (no general account found)") } diff --git a/datanode/sqlsubscribers/order.go b/datanode/sqlsubscribers/order.go index 78370bf57b5..ccedf2a9cd1 100644 --- a/datanode/sqlsubscribers/order.go +++ b/datanode/sqlsubscribers/order.go @@ -142,11 +142,15 @@ func (os *Order) cancelled(ctx context.Context, co CancelledOrdersEvent, seqNum ids = append(ids, id) } } - ncOrders, err := os.store.GetByMarketAndID(ctx, co.MarketID(), ids) - if err != nil { - return err + + if len(ids) > 0 { + ncOrders, err := os.store.GetByMarketAndID(ctx, co.MarketID(), ids) + if err != nil { + return err + } + orders = append(orders, ncOrders...) } - orders = append(orders, ncOrders...) + txHash := entities.TxHash(co.TxHash()) for _, o := range orders { o.Status = entities.OrderStatusCancelled