chainntnfs: signal reorg notification before required confirmations

In this commit, we send the reorg notification even when the
transaction has not yet reached the required confirmations, in
case the caller is interested in knowing about it.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
This commit is contained in:
Nishant Bansal committed 2025-09-11 18:24:54 +05:30
1 parent 0c2f045f5d
commit aa9c3272e3
2 files changed
+64

No files matched your search

+14
View File
@@ -2011,6 +2011,20 @@ func (n *TxNotifier) dispatchConfReorg(ntfn *ConfNtfn,
if !ntfn.dispatched {
confHeight := heightDisconnected + ntfn.NumConfirmations - 1
ntfnSet, exists := n.ntfnsByConfirmHeight[confHeight]
// We also signal the reorg to the notifier in case the
// subscriber is also interested in the reorgs before the
// transaction received its required confirmation.
//
// Because as soon as a new block is connected which has the
// transaction included again we preemptively read the buffered
// channel.
select {
case ntfn.Event.NegativeConf <- int32(n.reorgDepth):
case <-n.quit:
return ErrTxNotifierExiting
}
if exists {
delete(ntfnSet, ntfn)
}