Skip to content

Commit

Permalink
chainntnfs: skip dispatched conf details
Browse files Browse the repository at this point in the history
We need to check `dispatched` before sending conf details, otherwise the
channel `ntfn.Event.Confirmed` will be blocking, which is the leftover
from lightningnetwork#9275.
  • Loading branch information
yyforyongyu committed Dec 12, 2024
1 parent 411af91 commit bbf83c5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions chainntnfs/txnotifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1757,10 +1757,6 @@ func (n *TxNotifier) NotifyHeight(height uint32) error {
for ntfn := range n.ntfnsByConfirmHeight[height] {
confSet := n.confNotifications[ntfn.ConfRequest]

Log.Debugf("Dispatching %v confirmation notification for "+
"conf_id=%v, %v", ntfn.NumConfirmations, ntfn.ConfID,
ntfn.ConfRequest)

// The default notification we assigned above includes the
// block along with the rest of the details. However not all
// clients want the block, so we make a copy here w/o the block
Expand All @@ -1770,6 +1766,20 @@ func (n *TxNotifier) NotifyHeight(height uint32) error {
confDetails.Block = nil
}

// If the `confDetails` has already been sent before, we'll
// skip it and continue processing the next one.
if ntfn.dispatched {
Log.Debugf("Skipped dispatched conf details for "+
"request %v conf_id=%v", ntfn.ConfRequest,
ntfn.ConfID)

continue
}

Log.Debugf("Dispatching %v confirmation notification for "+
"conf_id=%v, %v", ntfn.NumConfirmations, ntfn.ConfID,
ntfn.ConfRequest)

select {
case ntfn.Event.Confirmed <- &confDetails:
ntfn.dispatched = true
Expand Down

0 comments on commit bbf83c5

Please sign in to comment.