Improve remove empty map on websocket unsubscribe
This commit is contained in:
parent
c2e32b0a25
commit
2a3c5426ca
@ -688,11 +688,11 @@ func (s *WebsocketServer) unsubscribeAddresses(c *websocketChannel) (res interfa
|
|||||||
for sc := range sa {
|
for sc := range sa {
|
||||||
if sc == c {
|
if sc == c {
|
||||||
delete(sa, c)
|
delete(sa, c)
|
||||||
if len(sa) == 0 {
|
|
||||||
delete(s.addressSubscriptions, ads)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(sa) == 0 {
|
||||||
|
delete(s.addressSubscriptions, ads)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &subscriptionResponse{false}, nil
|
return &subscriptionResponse{false}, nil
|
||||||
}
|
}
|
||||||
@ -720,12 +720,15 @@ func (s *WebsocketServer) subscribeFiatRates(c *websocketChannel, currency strin
|
|||||||
func (s *WebsocketServer) unsubscribeFiatRates(c *websocketChannel) (res interface{}, err error) {
|
func (s *WebsocketServer) unsubscribeFiatRates(c *websocketChannel) (res interface{}, err error) {
|
||||||
s.fiatRatesSubscriptionsLock.Lock()
|
s.fiatRatesSubscriptionsLock.Lock()
|
||||||
defer s.fiatRatesSubscriptionsLock.Unlock()
|
defer s.fiatRatesSubscriptionsLock.Unlock()
|
||||||
for _, sa := range s.fiatRatesSubscriptions {
|
for fr, sa := range s.fiatRatesSubscriptions {
|
||||||
for sc := range sa {
|
for sc := range sa {
|
||||||
if sc == c {
|
if sc == c {
|
||||||
delete(sa, c)
|
delete(sa, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(sa) == 0 {
|
||||||
|
delete(s.fiatRatesSubscriptions, fr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &subscriptionResponse{false}, nil
|
return &subscriptionResponse{false}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user