Clean up notification contexts and goroutines after ws disconnect.
This refactors the wallet notification code to reverse the order of how notification contexts are stored. Before, watched addresses and outpoints were used as keys, with a special reply channel as the value. This channel was read from and replies were marshalled and sent to the main wallet notification chan, but the goroutine handling this marshalling never exited because the reply channel was never closed (and couldn't have been, because there was no way to tell it was handling notifications for any particular wallet). Notification contexts are now primarily mapped by wallet notification channels, and code to send the notifications send directly to the wallet channel, with the previous goroutine reading the reply chan properly closing. The RPC code is also refactored with this change as well, to separate it more from websocket code. Websocket JSON extensions are no longer available to RPC clients. While here, unbreak RPC. Previously, replies were never sent back. This broke when I merged in my websocket code, as sends for the reply channel in jsonRead blocked before a reader for the channel was opened. A 3 liner could have fixed this, but doing a proper fix (changing jsonRead so it did not use the reply channel as it is unneeded for the standard RPC API) is preferred.
This commit is contained in:
parent
90fbae1781
commit
bbcfdcf5aa
1 changed files with 371 additions and 321 deletions
692
rpcserver.go
692
rpcserver.go
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue