Improve remove empty map on websocket unsubscribe
parent
c2e32b0a25
commit
2a3c5426ca
|
@ -688,11 +688,11 @@ func (s *WebsocketServer) unsubscribeAddresses(c *websocketChannel) (res interfa
|
|||
for sc := range sa {
|
||||
if sc == c {
|
||||
delete(sa, c)
|
||||
if len(sa) == 0 {
|
||||
delete(s.addressSubscriptions, ads)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(sa) == 0 {
|
||||
delete(s.addressSubscriptions, ads)
|
||||
}
|
||||
}
|
||||
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) {
|
||||
s.fiatRatesSubscriptionsLock.Lock()
|
||||
defer s.fiatRatesSubscriptionsLock.Unlock()
|
||||
for _, sa := range s.fiatRatesSubscriptions {
|
||||
for fr, sa := range s.fiatRatesSubscriptions {
|
||||
for sc := range sa {
|
||||
if sc == c {
|
||||
delete(sa, c)
|
||||
}
|
||||
}
|
||||
if len(sa) == 0 {
|
||||
delete(s.fiatRatesSubscriptions, fr)
|
||||
}
|
||||
}
|
||||
return &subscriptionResponse{false}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue