mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: after each new state update, notify callers to set of new HTLC's
This commit is contained in:
parent
1418d672f9
commit
2d133acaeb
@ -225,6 +225,10 @@ type channelLink struct {
|
|||||||
// be forwarded and/or accepted.
|
// be forwarded and/or accepted.
|
||||||
linkControl chan interface{}
|
linkControl chan interface{}
|
||||||
|
|
||||||
|
// htlcUpdates is a channel that we'll use to update outside
|
||||||
|
// sub-systems with the latest set of active HTLC's on our channel.
|
||||||
|
htlcUpdates chan []channeldb.HTLC
|
||||||
|
|
||||||
// logCommitTimer is a timer which is sent upon if we go an interval
|
// logCommitTimer is a timer which is sent upon if we go an interval
|
||||||
// without receiving/sending a commitment update. It's role is to
|
// without receiving/sending a commitment update. It's role is to
|
||||||
// ensure both chains converge to identical state in a timely manner.
|
// ensure both chains converge to identical state in a timely manner.
|
||||||
@ -251,6 +255,7 @@ func NewChannelLink(cfg ChannelLinkConfig, channel *lnwallet.LightningChannel,
|
|||||||
logCommitTimer: time.NewTimer(300 * time.Millisecond),
|
logCommitTimer: time.NewTimer(300 * time.Millisecond),
|
||||||
overflowQueue: newPacketQueue(lnwallet.MaxHTLCNumber / 2),
|
overflowQueue: newPacketQueue(lnwallet.MaxHTLCNumber / 2),
|
||||||
bestHeight: currentHeight,
|
bestHeight: currentHeight,
|
||||||
|
htlcUpdates: make(chan []channeldb.HTLC),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,6 +961,15 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
|||||||
}
|
}
|
||||||
l.cfg.Peer.SendMessage(nextRevocation)
|
l.cfg.Peer.SendMessage(nextRevocation)
|
||||||
|
|
||||||
|
// Since we just revoked our commitment, we may have a new set
|
||||||
|
// of HTLC's on our commitment, so we'll send them over our
|
||||||
|
// HTLC update channel so any callers can be notified.
|
||||||
|
select {
|
||||||
|
case l.htlcUpdates <- currentHtlcs:
|
||||||
|
case <-l.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// As we've just received a commitment signature, we'll
|
// As we've just received a commitment signature, we'll
|
||||||
// re-start the log commit timer to wake up the main processing
|
// re-start the log commit timer to wake up the main processing
|
||||||
// loop to check if we need to send a commitment signature as
|
// loop to check if we need to send a commitment signature as
|
||||||
|
Loading…
Reference in New Issue
Block a user