Remove empty map on address unsubscribe

pull/401/head
Kirill Fomichev 2020-03-14 19:28:02 +03:00 committed by Martin
parent 4338d10dcb
commit c2e32b0a25
1 changed files with 4 additions and 1 deletions

View File

@ -684,10 +684,13 @@ func (s *WebsocketServer) subscribeAddresses(c *websocketChannel, addrDesc []bch
func (s *WebsocketServer) unsubscribeAddresses(c *websocketChannel) (res interface{}, err error) {
s.addressSubscriptionsLock.Lock()
defer s.addressSubscriptionsLock.Unlock()
for _, sa := range s.addressSubscriptions {
for ads, sa := range s.addressSubscriptions {
for sc := range sa {
if sc == c {
delete(sa, c)
if len(sa) == 0 {
delete(s.addressSubscriptions, ads)
}
}
}
}