chain: keep track of lastFilteredBlockHeader within NeutrinoClient
Co-Authored-By: Roei Erez <roeierez@gmail.com>
This commit is contained in:
parent
8b90263a61
commit
8f25b8b4ef
1 changed files with 13 additions and 5 deletions
|
@ -32,6 +32,7 @@ type NeutrinoClient struct {
|
||||||
dequeueNotification chan interface{}
|
dequeueNotification chan interface{}
|
||||||
startTime time.Time
|
startTime time.Time
|
||||||
lastProgressSent bool
|
lastProgressSent bool
|
||||||
|
lastFilteredBlockHeader *wire.BlockHeader
|
||||||
currentBlock chan *waddrmgr.BlockStamp
|
currentBlock chan *waddrmgr.BlockStamp
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
@ -339,6 +340,7 @@ func (s *NeutrinoClient) Rescan(startHash *chainhash.Hash, addrs []btcutil.Addre
|
||||||
s.scanning = true
|
s.scanning = true
|
||||||
s.finished = false
|
s.finished = false
|
||||||
s.lastProgressSent = false
|
s.lastProgressSent = false
|
||||||
|
s.lastFilteredBlockHeader = nil
|
||||||
s.isRescan = true
|
s.isRescan = true
|
||||||
|
|
||||||
bestBlock, err := s.CS.BestBlock()
|
bestBlock, err := s.CS.BestBlock()
|
||||||
|
@ -432,6 +434,7 @@ func (s *NeutrinoClient) NotifyReceived(addrs []btcutil.Address) error {
|
||||||
// Don't need RescanFinished or RescanProgress notifications.
|
// Don't need RescanFinished or RescanProgress notifications.
|
||||||
s.finished = true
|
s.finished = true
|
||||||
s.lastProgressSent = true
|
s.lastProgressSent = true
|
||||||
|
s.lastFilteredBlockHeader = nil
|
||||||
|
|
||||||
// Rescan with just the specified addresses.
|
// Rescan with just the specified addresses.
|
||||||
newRescan := neutrino.NewRescan(
|
newRescan := neutrino.NewRescan(
|
||||||
|
@ -495,6 +498,7 @@ func (s *NeutrinoClient) onFilteredBlockConnected(height int32,
|
||||||
}
|
}
|
||||||
ntfn.RelevantTxs = append(ntfn.RelevantTxs, rec)
|
ntfn.RelevantTxs = append(ntfn.RelevantTxs, rec)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case s.enqueueNotification <- ntfn:
|
case s.enqueueNotification <- ntfn:
|
||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
|
@ -503,6 +507,10 @@ func (s *NeutrinoClient) onFilteredBlockConnected(height int32,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.clientMtx.Lock()
|
||||||
|
s.lastFilteredBlockHeader = header
|
||||||
|
s.clientMtx.Unlock()
|
||||||
|
|
||||||
// Handle RescanFinished notification if required.
|
// Handle RescanFinished notification if required.
|
||||||
bs, err := s.CS.BestBlock()
|
bs, err := s.CS.BestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue