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:
2 files changed
+64
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user