Skip to content

Commit

Permalink
server/book: clean uses correct heap orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Nov 2, 2020
1 parent dbf9d2c commit eb6ccd4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/book/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

const (
// DefaultBookHalfCapacity is the default capacity of one side (buy or sell)
// of the order book. It is set to 2^21 orders (2 mebiorders = 2,097,152
// of the order book. It is set to 2^20 orders (1 mebiorders = 1,048,576
// orders) per book side.
DefaultBookHalfCapacity uint32 = 1 << 21 // 4 * 2 MiB
DefaultBookHalfCapacity uint32 = 1 << 20
)

// Book is a market's order book. The Book uses a configurable lot size, of
Expand Down Expand Up @@ -50,8 +50,9 @@ func New(lotSize uint64, halfCapacity ...uint32) *Book {
// Clear reset the order book with configured capacity.
func (b *Book) Clear() {
b.mtx.Lock()
b.buys, b.sells = nil, nil
b.buys = NewMaxOrderPQ(b.halfCap)
b.sells = NewMaxOrderPQ(b.halfCap)
b.sells = NewMinOrderPQ(b.halfCap)
b.mtx.Unlock()
}

Expand Down

0 comments on commit eb6ccd4

Please sign in to comment.