add exists method for active book

This commit is contained in:
c9s 2021-05-22 17:44:07 +08:00
parent 0a908e5dda
commit 289227e5f3

View File

@ -111,6 +111,21 @@ func (b *LocalActiveOrderBook) NumOfAsks() int {
return b.Asks.Len()
}
func (b *LocalActiveOrderBook) Exists(order types.Order) bool {
switch order.Side {
case types.SideTypeBuy:
return b.Bids.Exists(order.OrderID)
case types.SideTypeSell:
return b.Asks.Exists(order.OrderID)
}
return false
}
func (b *LocalActiveOrderBook) Remove(order types.Order) bool {
switch order.Side {
case types.SideTypeBuy: