mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 21:51:27 +02:00
chainntnfs: add new method notifyNumConfsLeft
So it's easier to handle the following commit where we start skipping duplicate notifications.
This commit is contained in:
@@ -942,10 +942,9 @@ func (n *TxNotifier) dispatchConfDetails(
|
||||
// We'll send a 0 value to the Updates channel,
|
||||
// indicating that the transaction/output script has already
|
||||
// been confirmed.
|
||||
select {
|
||||
case ntfn.Event.Updates <- 0:
|
||||
case <-n.quit:
|
||||
return ErrTxNotifierExiting
|
||||
err := n.notifyNumConfsLeft(ntfn, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
select {
|
||||
@@ -972,10 +971,9 @@ func (n *TxNotifier) dispatchConfDetails(
|
||||
// confirmations are left for the transaction/output script to
|
||||
// be confirmed.
|
||||
numConfsLeft := confHeight - n.currentHeight
|
||||
select {
|
||||
case ntfn.Event.Updates <- numConfsLeft:
|
||||
case <-n.quit:
|
||||
return ErrTxNotifierExiting
|
||||
err := n.notifyNumConfsLeft(ntfn, numConfsLeft)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1740,10 +1738,9 @@ func (n *TxNotifier) NotifyHeight(height uint32) error {
|
||||
continue
|
||||
}
|
||||
|
||||
select {
|
||||
case ntfn.Event.Updates <- numConfsLeft:
|
||||
case <-n.quit:
|
||||
return ErrTxNotifierExiting
|
||||
err := n.notifyNumConfsLeft(ntfn, numConfsLeft)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2081,3 +2078,15 @@ func (n *TxNotifier) TearDown() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notifyNumConfsLeft sends the number of confirmations left to the
|
||||
// notification subscriber through the Event.Updates channel.
|
||||
func (n *TxNotifier) notifyNumConfsLeft(ntfn *ConfNtfn, num uint32) error {
|
||||
select {
|
||||
case ntfn.Event.Updates <- num:
|
||||
case <-n.quit:
|
||||
return ErrTxNotifierExiting
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user