chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected

This commit is contained in:
Wilmer Paulino 2019-04-19 12:27:33 -07:00
parent b386e6385e
commit e0f82255c7
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

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