wallet: stop handling chain notifications once wallet has stopped
In this commit, we alter the behavior for handling chain notifications within the wallet. The previous code would assume that the channel would close, but due to now using a ConcurrentQueue to handle notifications, this assumption no longer stands. Now, we'll stop handling notifications either once the wallet has or stopped or once the notifications channel has been closed.
This commit is contained in:
parent
bbb5a6c058
commit
dec9978ca2
1 changed files with 78 additions and 69 deletions
|
@ -16,10 +16,11 @@ import (
|
|||
)
|
||||
|
||||
func (w *Wallet) handleChainNotifications() {
|
||||
defer w.wg.Done()
|
||||
|
||||
chainClient, err := w.requireChainClient()
|
||||
if err != nil {
|
||||
log.Errorf("handleChainNotifications called without RPC client")
|
||||
w.wg.Done()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,13 @@ func (w *Wallet) handleChainNotifications() {
|
|||
return err
|
||||
}
|
||||
|
||||
for n := range chainClient.Notifications() {
|
||||
for {
|
||||
select {
|
||||
case n, ok := <-chainClient.Notifications():
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var notificationName string
|
||||
var err error
|
||||
switch n := n.(type) {
|
||||
|
@ -156,8 +163,10 @@ func (w *Wallet) handleChainNotifications() {
|
|||
log.Errorf(errStr, notificationName, err)
|
||||
}
|
||||
}
|
||||
case <-w.quit:
|
||||
return
|
||||
}
|
||||
}
|
||||
w.wg.Done()
|
||||
}
|
||||
|
||||
// connectBlock handles a chain server notification by marking a wallet
|
||||
|
|
Loading…
Reference in a new issue