@@ -3757,10 +3757,26 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
3757
3757
l .log .Tracef ("processing %d remote adds for height %d" ,
3758
3758
len (fwdPkg .Adds ), fwdPkg .Height )
3759
3759
3760
- decodeReqs := make (
3761
- []hop.DecodeHopIteratorRequest , 0 , len (fwdPkg .Adds ),
3762
- )
3763
- for _ , update := range fwdPkg .Adds {
3760
+ // decodeReqs is a list of requests sent to the onion decoder. We expect
3761
+ // the same length of responses to be returned.
3762
+ decodeReqs := make ([]hop.DecodeHopIteratorRequest , 0 , len (fwdPkg .Adds ))
3763
+
3764
+ // unackedAdds is a list of ADDs that's waiting for the remote's
3765
+ // settle/fail update.
3766
+ unackedAdds := make ([]* lnwire.UpdateAddHTLC , 0 , len (fwdPkg .Adds ))
3767
+
3768
+ for i , update := range fwdPkg .Adds {
3769
+ // If this index is already found in the ack filter, the
3770
+ // response to this forwarding decision has already been
3771
+ // committed by one of our commitment txns. ADDs in this state
3772
+ // are waiting for the rest of the fwding package to get acked
3773
+ // before being garbage collected.
3774
+ if fwdPkg .State == channeldb .FwdStateProcessed &&
3775
+ fwdPkg .AckFilter .Contains (uint16 (i )) {
3776
+
3777
+ continue
3778
+ }
3779
+
3764
3780
if msg , ok := update .UpdateMsg .(* lnwire.UpdateAddHTLC ); ok {
3765
3781
// Before adding the new htlc to the state machine,
3766
3782
// parse the onion object in order to obtain the
@@ -3777,6 +3793,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
3777
3793
}
3778
3794
3779
3795
decodeReqs = append (decodeReqs , req )
3796
+ unackedAdds = append (unackedAdds , msg )
3780
3797
}
3781
3798
}
3782
3799
@@ -3799,23 +3816,10 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
3799
3816
3800
3817
var switchPackets []* htlcPacket
3801
3818
3802
- for i , update := range fwdPkg . Adds {
3819
+ for i , update := range unackedAdds {
3803
3820
idx := uint16 (i )
3804
-
3805
- //nolint:forcetypeassert
3806
- add := * update .UpdateMsg .(* lnwire.UpdateAddHTLC )
3807
3821
sourceRef := fwdPkg .SourceRef (idx )
3808
-
3809
- if fwdPkg .State == channeldb .FwdStateProcessed &&
3810
- fwdPkg .AckFilter .Contains (idx ) {
3811
-
3812
- // If this index is already found in the ack filter,
3813
- // the response to this forwarding decision has already
3814
- // been committed by one of our commitment txns. ADDs
3815
- // in this state are waiting for the rest of the fwding
3816
- // package to get acked before being garbage collected.
3817
- continue
3818
- }
3822
+ add := * update
3819
3823
3820
3824
// An incoming HTLC add has been full-locked in. As a result we
3821
3825
// can now examine the forwarding details of the HTLC, and the
@@ -3835,8 +3839,10 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
3835
3839
add .ID , failureCode , add .OnionBlob , & sourceRef ,
3836
3840
)
3837
3841
3838
- l .log .Errorf ("unable to decode onion hop " +
3839
- "iterator: %v" , failureCode )
3842
+ l .log .Errorf ("unable to decode onion hop iterator " +
3843
+ "for htlc(id=%v, hash=%x): %v" , add .ID ,
3844
+ add .PaymentHash , failureCode )
3845
+
3840
3846
continue
3841
3847
}
3842
3848
0 commit comments