chain: keep track of lastFilteredBlockHeader within NeutrinoClient

Co-Authored-By: Roei Erez <roeierez@gmail.com>
This commit is contained in:
Wilmer Paulino 2019-04-18 19:23:05 -07:00
parent 8b90263a61
commit 8f25b8b4ef
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -32,6 +32,7 @@ type NeutrinoClient struct {
dequeueNotification chan interface{}
startTime time.Time
lastProgressSent bool
lastFilteredBlockHeader *wire.BlockHeader
currentBlock chan *waddrmgr.BlockStamp
quit chan struct{}
@ -339,6 +340,7 @@ func (s *NeutrinoClient) Rescan(startHash *chainhash.Hash, addrs []btcutil.Addre
s.scanning = true
s.finished = false
s.lastProgressSent = false
s.lastFilteredBlockHeader = nil
s.isRescan = true
bestBlock, err := s.CS.BestBlock()
@ -432,6 +434,7 @@ func (s *NeutrinoClient) NotifyReceived(addrs []btcutil.Address) error {
// Don't need RescanFinished or RescanProgress notifications.
s.finished = true
s.lastProgressSent = true
s.lastFilteredBlockHeader = nil
// Rescan with just the specified addresses.
newRescan := neutrino.NewRescan(
@ -495,6 +498,7 @@ func (s *NeutrinoClient) onFilteredBlockConnected(height int32,
}
ntfn.RelevantTxs = append(ntfn.RelevantTxs, rec)
}
select {
case s.enqueueNotification <- ntfn:
case <-s.quit:
@ -503,6 +507,10 @@ func (s *NeutrinoClient) onFilteredBlockConnected(height int32,
return
}
s.clientMtx.Lock()
s.lastFilteredBlockHeader = header
s.clientMtx.Unlock()
// Handle RescanFinished notification if required.
bs, err := s.CS.BestBlock()
if err != nil {