From b3643ed7a9f503f4af5372e1653eaa852c5a1f7e Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 18 Apr 2019 19:32:30 -0700 Subject: [PATCH] chain: dispatch RescanFinished notification after BlockConnected In this commit, we address a bug within the wallet when running with Neutrino where it wouldn't be able to mark it as synced with the chain due to not receiving a RescanFinished notification if it was a block behind the chain. This happened because of the order in which the notifications are delivered within the underlying Neutrino ChainService, FilteredBlockConnected gets dispatched before BlockConnected. This doesn't always work however because there is an implicit dependency between them in which BlockConnected must occur first. To address it, rather than switching the order in which the notifications are dispatched, we just check if we can dispatch the final RescanFinished notification after dispatching BlockConnected. Co-Authored-By: Roei Erez --- chain/neutrino.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/neutrino.go b/chain/neutrino.go index f2209ef..38231db 100644 --- a/chain/neutrino.go +++ b/chain/neutrino.go @@ -587,6 +587,10 @@ func (s *NeutrinoClient) onBlockConnected(hash *chainhash.Hash, height int32, case <-s.rescanQuit: } } + + // Check if we're able to dispatch our final RescanFinished notification + // after processing this block. + s.dispatchRescanFinished() } // dispatchRescanFinished determines whether we're able to dispatch our final