Skip to content

Commit dc60f78

Browse files
committed
htlcswitch: remove PaymentDescriptor conversion from reforwardSettleFails
This is part of a systematic removal of PaymentDescriptor from the mechanics of the htlcswitch package.
1 parent 957557a commit dc60f78

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

htlcswitch/switch.go

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,39 +1911,27 @@ func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.
19111911
// NOTE: This should mimic the behavior processRemoteSettleFails.
19121912
func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
19131913
for _, fwdPkg := range fwdPkgs {
1914-
settleFails, err := lnwallet.PayDescsFromRemoteLogUpdates(
1915-
fwdPkg.Source, fwdPkg.Height, fwdPkg.SettleFails,
1916-
)
1917-
if err != nil {
1918-
log.Errorf("Unable to process remote log updates: %v",
1919-
err)
1920-
continue
1921-
}
1922-
1923-
switchPackets := make([]*htlcPacket, 0, len(settleFails))
1924-
for i, pd := range settleFails {
1925-
1914+
switchPackets := make([]*htlcPacket, 0, len(fwdPkg.SettleFails))
1915+
for i, update := range fwdPkg.SettleFails {
19261916
// Skip any settles or fails that have already been
19271917
// acknowledged by the incoming link that originated the
19281918
// forwarded Add.
19291919
if fwdPkg.SettleFailFilter.Contains(uint16(i)) {
19301920
continue
19311921
}
19321922

1933-
switch pd.EntryType {
1934-
1923+
switch msg := update.UpdateMsg.(type) {
19351924
// A settle for an HTLC we previously forwarded HTLC has
19361925
// been received. So we'll forward the HTLC to the
19371926
// switch which will handle propagating the settle to
19381927
// the prior hop.
1939-
case lnwallet.Settle:
1928+
case *lnwire.UpdateFulfillHTLC:
1929+
destRef := fwdPkg.DestRef(uint16(i))
19401930
settlePacket := &htlcPacket{
19411931
outgoingChanID: fwdPkg.Source,
1942-
outgoingHTLCID: pd.ParentIndex,
1943-
destRef: pd.DestRef,
1944-
htlc: &lnwire.UpdateFulfillHTLC{
1945-
PaymentPreimage: pd.RPreimage,
1946-
},
1932+
outgoingHTLCID: msg.ID,
1933+
destRef: &destRef,
1934+
htlc: msg,
19471935
}
19481936

19491937
// Add the packet to the batch to be forwarded, and
@@ -1955,7 +1943,7 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
19551943
// received. As a result a new slot will be freed up in our
19561944
// commitment state, so we'll forward this to the switch so the
19571945
// backwards undo can continue.
1958-
case lnwallet.Fail:
1946+
case *lnwire.UpdateFailHTLC:
19591947
// Fetch the reason the HTLC was canceled so
19601948
// we can continue to propagate it. This
19611949
// failure originated from another node, so
@@ -1964,11 +1952,13 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
19641952
// additional circuit information for us.
19651953
failPacket := &htlcPacket{
19661954
outgoingChanID: fwdPkg.Source,
1967-
outgoingHTLCID: pd.ParentIndex,
1968-
destRef: pd.DestRef,
1969-
htlc: &lnwire.UpdateFailHTLC{
1970-
Reason: lnwire.OpaqueReason(pd.FailReason),
1955+
outgoingHTLCID: msg.ID,
1956+
destRef: &channeldb.SettleFailRef{
1957+
Source: fwdPkg.Source,
1958+
Height: fwdPkg.Height,
1959+
Index: uint16(i),
19711960
},
1961+
htlc: msg,
19721962
}
19731963

19741964
// Add the packet to the batch to be forwarded, and

0 commit comments

Comments
 (0)