chainntnfs: remove queued confirmation notification in CancelConf

This addresses a panic when a notification is canceled after its been
detected as included in a block and before its confirmation notification
is dispatched.
This commit is contained in:
Wilmer Paulino committed 2020-06-10 13:45:45 -07:00
1 parent be36776120
commit 69b8a356b2
2 files changed
+39 -6

No files matched your search

+14
View File
@@ -752,7 +752,21 @@ func (n *TxNotifier) CancelConf(confRequest ConfRequest, confID uint64) {
close(ntfn.Event.Confirmed)
close(ntfn.Event.Updates)
close(ntfn.Event.NegativeConf)
// Finally, we'll clean up any lingering references to this
// notification.
delete(confSet.ntfns, confID)
// Remove the queued confirmation notification if the transaction has
// already confirmed, but hasn't met its required number of
// confirmations.
if confSet.details != nil {
confHeight := confSet.details.BlockHeight +
ntfn.NumConfirmations - 1
if confHeight <= n.currentHeight {
delete(n.ntfnsByConfirmHeight[confHeight], ntfn)
}
}
}
// UpdateConfDetails attempts to update the confirmation details for an active