Remove tracking requests from websocket client too.

When a spent notification and address notification is removed, the
tracking entry in the client which is used to track what to remove on
shutdown needs to be removed as well.
This commit is contained in:
Dave Collins 2014-02-19 09:13:49 -06:00
parent 7d35bc9460
commit 7162a11995

View file

@ -341,6 +341,10 @@ func (m *wsNotificationManager) AddSpentRequest(wsc *wsClient, op *btcwire.OutPo
//
// This function MUST be called with the notification manager lock held.
func (m *wsNotificationManager) removeSpentRequest(wsc *wsClient, op *btcwire.OutPoint) {
// Remove the request tracking from the client.
delete(wsc.spentRequests, *op)
// Remove the client from the list to notify.
notifyMap, ok := m.spentNotifications[*op]
if !ok {
rpcsLog.Warnf("Attempt to remove nonexistent spent request "+
@ -533,13 +537,16 @@ func (m *wsNotificationManager) AddAddrRequest(wsc *wsClient, addr string) {
//
// This function MUST be called with the notification manager lock held.
func (m *wsNotificationManager) removeAddrRequest(wsc *wsClient, addr string) {
// Remove the request tracking from the client.
delete(wsc.addrRequests, addr)
// Remove the client from the list to notify.
notifyMap, ok := m.addrNotifications[addr]
if !ok {
rpcsLog.Warnf("Attempt to remove nonexistent addr request "+
"<%s> for websocket client %s", addr, wsc.addr)
return
}
delete(notifyMap, wsc.quit)
// Remove the map entry altogether if there are no more clients