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
|
@ -28,11 +28,12 @@ type NeutrinoClient struct {
|
||||||
// We currently support one rescan/notifiction goroutine per client
|
// We currently support one rescan/notifiction goroutine per client
|
||||||
rescan *neutrino.Rescan
|
rescan *neutrino.Rescan
|
||||||
|
|
||||||
enqueueNotification chan interface{}
|
enqueueNotification chan interface{}
|
||||||
dequeueNotification chan interface{}
|
dequeueNotification chan interface{}
|
||||||
startTime time.Time
|
startTime time.Time
|
||||||
lastProgressSent bool
|
lastProgressSent bool
|
||||||
currentBlock chan *waddrmgr.BlockStamp
|
lastFilteredBlockHeader *wire.BlockHeader
|
||||||
|
currentBlock chan *waddrmgr.BlockStamp
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
rescanQuit chan struct{}
|
rescanQuit 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