Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return a fresh pointer from orderstore.getByDetail
Browse files Browse the repository at this point in the history
This protects the order.Details in the store from direct access.
The use-case was to allow the returned objects to be references so that
future changes to them would be reflected.
However we're not ready yet to allow people to touch the orders
directly, because they're not protected directly by a mutex, and nothing
would stop consumers contaminating the integrity of the data.

We can revisit this topic later atomicly, but it's definitely tangental
to the cause of action for PR thrasher-corp#1336.
gbjk committed Sep 11, 2023
1 parent 018bae3 commit bddd6b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion engine/order_manager.go
Original file line number Diff line number Diff line change
@@ -1062,7 +1062,7 @@ func (s *store) getByDetail(det *order.Detail) *order.Detail {
exchangeOrders := s.Orders[strings.ToLower(det.Exchange)]
for _, o := range exchangeOrders {
if o.OrderID == det.OrderID {
return o
return o.CopyToPointer()
}
}
return nil

0 comments on commit bddd6b3

Please sign in to comment.