mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 07:26:50 +00:00
orderbook: Check assignment of time values and reject if not set (#1318)
* orderbook: Check assignment of time values and reject if not set. * linter: fix * buffer: additional linter winter fixter * Implement through pending exchanges * finished push * linty: minty * gomod: tidy * thrasher: nits * glorious: nits * orderbook: purge type now in favour of external call allocation * orderbook: push last param * orderbook: only 1 unlock call is needed --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -245,7 +245,10 @@ func (w *Orderbook) processObUpdate(o *orderbookHolder, u *orderbook.Update) err
|
||||
if w.updateEntriesByID {
|
||||
return o.updateByIDAndAction(u)
|
||||
}
|
||||
o.updateByPrice(u)
|
||||
err := o.updateByPrice(u)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if w.checksum != nil {
|
||||
compare, err := o.ob.Retrieve()
|
||||
if err != nil {
|
||||
@@ -262,8 +265,8 @@ func (w *Orderbook) processObUpdate(o *orderbookHolder, u *orderbook.Update) err
|
||||
|
||||
// updateByPrice amends amount if match occurs by price, deletes if amount is
|
||||
// zero or less and inserts if not found.
|
||||
func (o *orderbookHolder) updateByPrice(updts *orderbook.Update) {
|
||||
o.ob.UpdateBidAskByPrice(updts)
|
||||
func (o *orderbookHolder) updateByPrice(updts *orderbook.Update) error {
|
||||
return o.ob.UpdateBidAskByPrice(updts)
|
||||
}
|
||||
|
||||
// updateByIDAndAction will receive an action to execute against the orderbook
|
||||
@@ -328,11 +331,15 @@ func (w *Orderbook) LoadSnapshot(book *orderbook.Base) error {
|
||||
}
|
||||
|
||||
holder.updateID = book.LastUpdateID
|
||||
holder.ob.LoadSnapshot(book.Bids,
|
||||
|
||||
err = holder.ob.LoadSnapshot(book.Bids,
|
||||
book.Asks,
|
||||
book.LastUpdateID,
|
||||
book.LastUpdated,
|
||||
false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if holder.ob.VerifyOrderbook {
|
||||
// This is used here so as to not retrieve book if verification is off.
|
||||
|
||||
Reference in New Issue
Block a user