From 78ea2cdc9c2605d45ce284ff37a6e123665f12f6 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 3 Jul 2018 18:59:17 -0700 Subject: [PATCH] wallet/chainntfns: ensure safe shutdown during sync --- wallet/chainntfns.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wallet/chainntfns.go b/wallet/chainntfns.go index 393701b..e110cb2 100644 --- a/wallet/chainntfns.go +++ b/wallet/chainntfns.go @@ -128,12 +128,20 @@ func (w *Wallet) handleChainNotifications() { case *chain.RescanProgress: err = catchUpHashes(w, chainClient, n.Height) notificationName = "rescanprogress" - w.rescanNotifications <- n + select { + case w.rescanNotifications <- n: + case <-w.quitChan(): + return + } case *chain.RescanFinished: err = catchUpHashes(w, chainClient, n.Height) notificationName = "rescanprogress" w.SetChainSynced(true) - w.rescanNotifications <- n + select { + case w.rescanNotifications <- n: + case <-w.quitChan(): + return + } } if err != nil { // On out-of-sync blockconnected notifications, only