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)
|
return time.Duration(prand.Int63n(upper-lower) + lower)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDownstreamPkt processes an HTLC packet sent from the downstream HTLC
|
// handleDownstreamUpdateAdd processes an UpdateAddHTLC packet sent from the
|
||||||
// Switch. Possible messages sent by the switch include requests to forward new
|
// downstream HTLC Switch.
|
||||||
// HTLCs, timeout previously cleared HTLCs, and finally to settle currently
|
func (l *channelLink) handleDownstreamUpdateAdd(pkt *htlcPacket) {
|
||||||
// cleared HTLCs with the upstream peer.
|
htlc := pkt.htlc.(*lnwire.UpdateAddHTLC)
|
||||||
//
|
|
||||||
// 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:
|
|
||||||
// If hodl.AddOutgoing mode is active, we exit early to simulate
|
// If hodl.AddOutgoing mode is active, we exit early to simulate
|
||||||
// arbitrary delays between the switch adding an ADD to the
|
// arbitrary delays between the switch adding an ADD to the
|
||||||
// mailbox, and the HTLC being added to the commitment state.
|
// 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.openedCircuits = append(l.openedCircuits, pkt.inKey())
|
||||||
l.keystoneBatch = append(l.keystoneBatch, pkt.keystone())
|
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.
|
// Send a forward event notification to htlcNotifier.
|
||||||
l.cfg.HtlcNotifier.NotifyForwardingEvent(
|
l.cfg.HtlcNotifier.NotifyForwardingEvent(
|
||||||
@ -1328,6 +1324,18 @@ func (l *channelLink) handleDownstreamPkt(pkt *htlcPacket) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
l.tryBatchUpdateCommitTx()
|
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:
|
case *lnwire.UpdateFulfillHTLC:
|
||||||
// If hodl.SettleOutgoing mode is active, we exit early to
|
// If hodl.SettleOutgoing mode is active, we exit early to
|
||||||
|
Loading…
Reference in New Issue
Block a user