From bddd6b3feb02c6754a2521f9ba3e1ed55cefda27 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Mon, 11 Sep 2023 16:49:26 +0700 Subject: [PATCH] Return a fresh pointer from orderstore.getByDetail 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 #1336. --- engine/order_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/order_manager.go b/engine/order_manager.go index 84fb9266a0a..58d0abac162 100644 --- a/engine/order_manager.go +++ b/engine/order_manager.go @@ -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