Merge pull request #614 from wpaulino/on-block-connected-panic

chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected
This commit is contained in:
Olaoluwa Osuntokun 2019-04-24 15:40:17 -07:00 committed by GitHub
commit 9d95f76e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()