diff --git a/pkg/morph/client/notifications.go b/pkg/morph/client/notifications.go index 0c26eca2f2b..cf755db2e80 100644 --- a/pkg/morph/client/notifications.go +++ b/pkg/morph/client/notifications.go @@ -206,8 +206,6 @@ func (c *Client) Notifications() (<-chan *state.ContainedNotificationEvent, <-ch } type subscriptions struct { - sync.RWMutex - // notification consumers (Client sends // notifications to these channels) notifyChan chan *state.ContainedNotificationEvent @@ -220,6 +218,8 @@ type subscriptions struct { curBlockChan chan *block.Block curNotaryChan chan *result.NotaryRequestEvent + sync.RWMutex // for subscription fields only + // cached subscription information subscribedEvents map[util.Uint160]struct{} subscribedToAllNotaryEvents bool @@ -237,11 +237,11 @@ func (c *Client) routeNotifications() { routeloop: for { var connLost bool - c.subs.RLock() + c.switchLock.RLock() notifCh := c.subs.curNotifyChan blCh := c.subs.curBlockChan notaryCh := c.subs.curNotaryChan - c.subs.RUnlock() + c.switchLock.RUnlock() select { case <-c.closeChan: break routeloop