Skip to content

Commit 3b9c4eb

Browse files
committed
htlcswitch: exit early if the fwdPkg is already completed
1 parent fb95458 commit 3b9c4eb

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

htlcswitch/link.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3632,6 +3632,13 @@ func (l *channelLink) processRemoteSettleFails(fwdPkg *channeldb.FwdPkg) {
36323632
return
36333633
}
36343634

3635+
// Exit early if the fwdPkg is already processed.
3636+
if fwdPkg.State == channeldb.FwdStateCompleted {
3637+
l.log.Debugf("skipped processing completed fwdPkg %v", fwdPkg)
3638+
3639+
return
3640+
}
3641+
36353642
l.log.Debugf("settle-fail-filter: %v", fwdPkg.SettleFailFilter)
36363643

36373644
var switchPackets []*htlcPacket
@@ -3740,6 +3747,13 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
37403747
return
37413748
}
37423749

3750+
// Exit early if the fwdPkg is already processed.
3751+
if fwdPkg.State == channeldb.FwdStateCompleted {
3752+
l.log.Debugf("skipped processing completed fwdPkg %v", fwdPkg)
3753+
3754+
return
3755+
}
3756+
37433757
l.log.Tracef("processing %d remote adds for height %d",
37443758
len(fwdPkg.Adds), fwdPkg.Height)
37453759

@@ -3766,7 +3780,9 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
37663780
}
37673781
}
37683782

3769-
reforward := fwdPkg.State != channeldb.FwdStateLockedIn
3783+
// If the fwdPkg has already been processed, it means we are
3784+
// reforwarding the packets again, which happens only on a restart.
3785+
reforward := fwdPkg.State == channeldb.FwdStateProcessed
37703786

37713787
// Atomically decode the incoming htlcs, simultaneously checking for
37723788
// replay attempts. A particular index in the returned, spare list of

0 commit comments

Comments
 (0)