mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: extract handleDownstreamUpdateAdd in link
To be able to call just the UpdateAdd logic for synchronously handled local adds in a later commit.
This commit is contained in:
parent
55930df70d
commit
de2df5606a
@ -1254,15 +1254,11 @@ func (l *channelLink) randomFeeUpdateTimeout() time.Duration {
|
||||
return time.Duration(prand.Int63n(upper-lower) + lower)
|
||||
}
|
||||
|
||||
// handleDownstreamPkt processes an HTLC packet sent from the downstream HTLC
|
||||
// Switch. Possible messages sent by the switch include requests to forward new
|
||||
// HTLCs, timeout previously cleared HTLCs, and finally to settle currently
|
||||
// cleared HTLCs with the upstream peer.
|
||||
//
|
||||
// TODO(roasbeef): add sync ntfn to ensure switch always has consistent view?
|
||||
func (l *channelLink) handleDownstreamPkt(pkt *htlcPacket) {
|
||||
switch htlc := pkt.htlc.(type) {
|
||||
case *lnwire.UpdateAddHTLC:
|
||||
// handleDownstreamUpdateAdd processes an UpdateAddHTLC packet sent from the
|
||||
// downstream HTLC Switch.
|
||||
func (l *channelLink) handleDownstreamUpdateAdd(pkt *htlcPacket) {
|
||||
htlc := pkt.htlc.(*lnwire.UpdateAddHTLC)
|
||||
|
||||
// If hodl.AddOutgoing mode is active, we exit early to simulate
|
||||
// arbitrary delays between the switch adding an ADD to the
|
||||
// mailbox, and the HTLC being added to the commitment state.
|
||||
@ -1313,7 +1309,7 @@ func (l *channelLink) handleDownstreamPkt(pkt *htlcPacket) {
|
||||
l.openedCircuits = append(l.openedCircuits, pkt.inKey())
|
||||
l.keystoneBatch = append(l.keystoneBatch, pkt.keystone())
|
||||
|
||||
l.cfg.Peer.SendMessage(false, htlc)
|
||||
_ = l.cfg.Peer.SendMessage(false, htlc)
|
||||
|
||||
// Send a forward event notification to htlcNotifier.
|
||||
l.cfg.HtlcNotifier.NotifyForwardingEvent(
|
||||
@ -1328,6 +1324,18 @@ func (l *channelLink) handleDownstreamPkt(pkt *htlcPacket) {
|
||||
)
|
||||
|
||||
l.tryBatchUpdateCommitTx()
|
||||
}
|
||||
|
||||
// handleDownstreamPkt processes an HTLC packet sent from the downstream HTLC
|
||||
// Switch. Possible messages sent by the switch include requests to forward new
|
||||
// HTLCs, timeout previously cleared HTLCs, and finally to settle currently
|
||||
// cleared HTLCs with the upstream peer.
|
||||
//
|
||||
// TODO(roasbeef): add sync ntfn to ensure switch always has consistent view?
|
||||
func (l *channelLink) handleDownstreamPkt(pkt *htlcPacket) {
|
||||
switch htlc := pkt.htlc.(type) {
|
||||
case *lnwire.UpdateAddHTLC:
|
||||
l.handleDownstreamUpdateAdd(pkt)
|
||||
|
||||
case *lnwire.UpdateFulfillHTLC:
|
||||
// If hodl.SettleOutgoing mode is active, we exit early to
|
||||
|
Loading…
Reference in New Issue
Block a user