wallet/chainntfns: ensure safe shutdown during sync

This commit is contained in:
Conner Fromknecht 2018-07-03 18:59:17 -07:00 committed by Olaoluwa Osuntokun
parent 74a7124666
commit 78ea2cdc9c

View file

@ -128,12 +128,20 @@ func (w *Wallet) handleChainNotifications() {
case *chain.RescanProgress: case *chain.RescanProgress:
err = catchUpHashes(w, chainClient, n.Height) err = catchUpHashes(w, chainClient, n.Height)
notificationName = "rescanprogress" notificationName = "rescanprogress"
w.rescanNotifications <- n select {
case w.rescanNotifications <- n:
case <-w.quitChan():
return
}
case *chain.RescanFinished: case *chain.RescanFinished:
err = catchUpHashes(w, chainClient, n.Height) err = catchUpHashes(w, chainClient, n.Height)
notificationName = "rescanprogress" notificationName = "rescanprogress"
w.SetChainSynced(true) w.SetChainSynced(true)
w.rescanNotifications <- n select {
case w.rescanNotifications <- n:
case <-w.quitChan():
return
}
} }
if err != nil { if err != nil {
// On out-of-sync blockconnected notifications, only // On out-of-sync blockconnected notifications, only