@@ -847,18 +847,23 @@ func (l *channelLink) htlcManager() {
847
847
848
848
// After cleaning up any memory pertaining to incoming packets, we now
849
849
// replay our forwarding packages to handle any htlcs that can be
850
- // processed locally, or need to be forwarded out to the switch.
851
- if err := l .resolveFwdPkgs (); err != nil {
852
- l .fail (LinkFailureError {code : ErrInternalError },
853
- "unable to resolve fwd pkgs: %v" , err )
854
- return
855
- }
850
+ // processed locally, or need to be forwarded out to the switch. We will
851
+ // only attempt to resolve packages if our short chan id indicates that
852
+ // the channel is not pending, otherwise we should have no htlcs to
853
+ // reforward.
854
+ if l .ShortChanID () != sourceHop {
855
+ if err := l .resolveFwdPkgs (); err != nil {
856
+ l .fail (LinkFailureError {code : ErrInternalError },
857
+ "unable to resolve fwd pkgs: %v" , err )
858
+ return
859
+ }
856
860
857
- // With our link's in-memory state fully reconstructed, spawn a
858
- // goroutine to manage the reclamation of disk space occupied by
859
- // completed forwarding packages.
860
- l .wg .Add (1 )
861
- go l .fwdPkgGarbager ()
861
+ // With our link's in-memory state fully reconstructed, spawn a
862
+ // goroutine to manage the reclamation of disk space occupied by
863
+ // completed forwarding packages.
864
+ l .wg .Add (1 )
865
+ go l .fwdPkgGarbager ()
866
+ }
862
867
863
868
out:
864
869
for {
@@ -1770,6 +1775,11 @@ func (l *channelLink) UpdateShortChanID() (lnwire.ShortChannelID, error) {
1770
1775
}
1771
1776
}()
1772
1777
1778
+ // Now that the short channel ID has been properly updated, we can begin
1779
+ // garbage collecting any forwarding packages we create.
1780
+ l .wg .Add (1 )
1781
+ go l .fwdPkgGarbager ()
1782
+
1773
1783
return sid , nil
1774
1784
}
1775
1785
0 commit comments