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
2020-06-04 17:19:07 -07:00
parent be36776120
commit 69b8a356b2
2 changed files with 39 additions and 6 deletions

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