stream/buffer: Improve orderbook verification conditions and fix TestUpdateByIDAndAction test (#1682)

* don't need to verify if checksum available; don't retroactively verify snapshots

* glorious: nits + allow checksum/validation to be done on updateByIDAndAction

* possible slice manipulation issue fix for test

* thrasher: nit

* this should fix it now

* for subsystem usage disallow deploying a book twice

* reverts strict policy using deploy, it's used in a bunch of tests I don't want to touch just yet, left a note

* rm unused variable

* glorious: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2024-11-11 14:46:14 +11:00
committed by GitHub
parent a2a7fed273
commit 4de4e3dc14
4 changed files with 346 additions and 583 deletions

View File

@@ -79,8 +79,7 @@ func (s *Service) Update(b *Base) error {
return s.Mux.Publish(book, m1.ID)
}
// DeployDepth used for subsystem deployment creates a depth item in the struct
// then returns a ptr to that Depth item
// DeployDepth used for subsystem deployment creates a depth item in the struct then returns a ptr to that Depth item
func (s *Service) DeployDepth(exchange string, p currency.Pair, a asset.Item) (*Depth, error) {
if exchange == "" {
return nil, errExchangeNameUnset
@@ -112,13 +111,15 @@ func (s *Service) DeployDepth(exchange string, p currency.Pair, a asset.Item) (*
s.books[strings.ToLower(exchange)] = m1
}
book, ok := m1.m[mapKey]
if !ok {
book = NewDepth(m1.ID)
book.exchange = exchange
book.pair = p
book.asset = a
m1.m[mapKey] = book
if ok {
// Maybe in future we should return an error here and be more strict.
return book, nil
}
book = NewDepth(m1.ID)
book.exchange = exchange
book.pair = p
book.asset = a
m1.m[mapKey] = book
return book, nil
}