chainntnfs/neutrinonotify: update EndHeight after filter update

After the error is received on the filter update errChan, update the
EndHeight if we're performing a historical scan. If a block was mined
after the call to RegisterConf/RegisterSpend but before the filter was
updated, then the block would not have the filter applied. This means
that a block containing the desired conf/spend parameters would be
undetected. Fix this by ensuring the historical scan also includes this
height, as it would previously not be included.
This commit is contained in:
eugene 2021-07-16 15:47:51 -04:00
parent 0d39c0799a
commit de71195bcb
No known key found for this signature in database
GPG Key ID: 118759E83439A9B1

View File

@ -777,6 +777,14 @@ func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
return ntfn.Event, nil
}
// Grab the current best height as the height may have been updated
// while we were draining the chainUpdates queue.
n.bestBlockMtx.RLock()
currentHeight := uint32(n.bestBlock.Height)
n.bestBlockMtx.RUnlock()
ntfn.HistoricalDispatch.EndHeight = currentHeight
// With the filter updated, we'll dispatch our historical rescan to
// ensure we detect the spend if it happened in the past.
n.wg.Add(1)
@ -929,6 +937,14 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
return ntfn.Event, nil
}
// Grab the current best height as the height may have been updated
// while we were draining the chainUpdates queue.
n.bestBlockMtx.RLock()
currentHeight := uint32(n.bestBlock.Height)
n.bestBlockMtx.RUnlock()
ntfn.HistoricalDispatch.EndHeight = currentHeight
// Finally, with the filter updated, we can dispatch the historical
// rescan to ensure we can detect if the event happened in the past.
select {