htlcswitch: remove PaymentDescriptor conversion from reforwardSettleFails

This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
This commit is contained in:
Keagan McClelland committed 2024-09-09 20:59:41 -06:00
1 parent 957557a937
commit dc60f78f7f
1 file changed
+15 -25
+15 -25
View File
@@ -1911,18 +1911,8 @@ func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.
// NOTE: This should mimic the behavior processRemoteSettleFails. // NOTE: This should mimic the behavior processRemoteSettleFails.
func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) { func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
for _, fwdPkg := range fwdPkgs { for _, fwdPkg := range fwdPkgs {
settleFails, err := lnwallet.PayDescsFromRemoteLogUpdates( switchPackets := make([]*htlcPacket, 0, len(fwdPkg.SettleFails))
fwdPkg.Source, fwdPkg.Height, fwdPkg.SettleFails, for i, update := range fwdPkg.SettleFails {
)
if err != nil {
log.Errorf("Unable to process remote log updates: %v",
err)
continue
}
switchPackets := make([]*htlcPacket, 0, len(settleFails))
for i, pd := range settleFails {
// Skip any settles or fails that have already been // Skip any settles or fails that have already been
// acknowledged by the incoming link that originated the // acknowledged by the incoming link that originated the
// forwarded Add. // forwarded Add.
@@ -1930,20 +1920,18 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
continue continue
} }
switch pd.EntryType { switch msg := update.UpdateMsg.(type) {
// A settle for an HTLC we previously forwarded HTLC has // A settle for an HTLC we previously forwarded HTLC has
// been received. So we'll forward the HTLC to the // been received. So we'll forward the HTLC to the
// switch which will handle propagating the settle to // switch which will handle propagating the settle to
// the prior hop. // the prior hop.
case lnwallet.Settle: case *lnwire.UpdateFulfillHTLC:
destRef := fwdPkg.DestRef(uint16(i))
settlePacket := &htlcPacket{ settlePacket := &htlcPacket{
outgoingChanID: fwdPkg.Source, outgoingChanID: fwdPkg.Source,
outgoingHTLCID: pd.ParentIndex, outgoingHTLCID: msg.ID,
destRef: pd.DestRef, destRef: &destRef,
htlc: &lnwire.UpdateFulfillHTLC{ htlc: msg,
PaymentPreimage: pd.RPreimage,
},
} }
// Add the packet to the batch to be forwarded, and // Add the packet to the batch to be forwarded, and
@@ -1955,7 +1943,7 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
// received. As a result a new slot will be freed up in our // received. As a result a new slot will be freed up in our
// commitment state, so we'll forward this to the switch so the // commitment state, so we'll forward this to the switch so the
// backwards undo can continue. // backwards undo can continue.
case lnwallet.Fail: case *lnwire.UpdateFailHTLC:
// Fetch the reason the HTLC was canceled so // Fetch the reason the HTLC was canceled so
// we can continue to propagate it. This // we can continue to propagate it. This
// failure originated from another node, so // failure originated from another node, so
@@ -1964,11 +1952,13 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
// additional circuit information for us. // additional circuit information for us.
failPacket := &htlcPacket{ failPacket := &htlcPacket{
outgoingChanID: fwdPkg.Source, outgoingChanID: fwdPkg.Source,
outgoingHTLCID: pd.ParentIndex, outgoingHTLCID: msg.ID,
destRef: pd.DestRef, destRef: &channeldb.SettleFailRef{
htlc: &lnwire.UpdateFailHTLC{ Source: fwdPkg.Source,
Reason: lnwire.OpaqueReason(pd.FailReason), Height: fwdPkg.Height,
Index: uint16(i),
}, },
htlc: msg,
} }
// Add the packet to the batch to be forwarded, and // Add the packet to the batch to be forwarded, and