From e0f82255c7eaa62d87c46ced211167c3a970c568 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 19 Apr 2019 12:27:33 -0700 Subject: [PATCH] chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected --- chain/neutrino.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chain/neutrino.go b/chain/neutrino.go index 38231db..fb109b4 100644 --- a/chain/neutrino.go +++ b/chain/neutrino.go @@ -605,19 +605,19 @@ func (s *NeutrinoClient) dispatchRescanFinished() { } s.clientMtx.Lock() - if bs.Hash != s.lastFilteredBlockHeader.BlockHash() { - s.clientMtx.Unlock() - return - } - // Only send the RescanFinished notification once. - if s.finished { + if s.lastFilteredBlockHeader == nil || s.finished { s.clientMtx.Unlock() return } // Only send the RescanFinished notification once the underlying chain // service sees itself as current. + if bs.Hash != s.lastFilteredBlockHeader.BlockHash() { + s.clientMtx.Unlock() + return + } + s.finished = s.CS.IsCurrent() && s.lastProgressSent if !s.finished { s.clientMtx.Unlock()