activeorderbook: add pending order logs

This commit is contained in:
c9s 2023-09-17 17:42:17 +08:00
parent 4a8407bde3
commit 5f8a5e47d5
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -59,7 +59,9 @@ func (b *ActiveOrderBook) BindStream(stream types.Stream) {
stream.OnOrderUpdate(b.orderUpdateHandler)
}
func (b *ActiveOrderBook) waitClear(ctx context.Context, order types.Order, waitTime, timeout time.Duration) (bool, error) {
func (b *ActiveOrderBook) waitClear(
ctx context.Context, order types.Order, waitTime, timeout time.Duration,
) (bool, error) {
if !b.orders.Exists(order.OrderID) {
return true, nil
}
@ -266,6 +268,7 @@ func (b *ActiveOrderBook) Update(order types.Order) {
b.mu.Lock()
if !b.orders.Exists(order.OrderID) {
log.Infof("[ActiveOrderBook] order #%d does not exist, adding it to pending order update", order.OrderID)
b.pendingOrderUpdates.Add(order)
b.mu.Unlock()
return
@ -275,6 +278,7 @@ func (b *ActiveOrderBook) Update(order types.Order) {
if previousOrder, ok := b.orders.Get(order.OrderID); ok {
previousUpdateTime := previousOrder.UpdateTime.Time()
if !previousUpdateTime.IsZero() && order.UpdateTime.Before(previousUpdateTime) {
log.Infof("[ActiveOrderBook] order #%d updateTime is out of date, skip it", order.OrderID)
b.mu.Unlock()
return
}