From 3fb6a310f87bff2c4d7620714d3b442354ae2702 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Sat, 18 Aug 2018 19:35:20 -0700 Subject: [PATCH] htlcswitch/link: remove circuit deletion forgiveness This commit removes the concept of "circuit deletion forgivness" from the link. This was originally implemented due to the strict semantics of the original DeleteCircuit implementation, which would fail if we tried to delete unknown circuits. Forgivness is used on startup to ignore this error in case the circuits had already been deleted before shutting down. Now that the circuit deletion has been relaxed, this behavior is no longer necessary, as requests to delete unknown (or previously deleted) circuits will be ignored. This is necessary for future changes regarding switch cleanup, which may attempt to cleanup already deleted circuits. --- htlcswitch/link.go | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 3112b8ed..0c1df9dc 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -585,7 +585,7 @@ func (l *channelLink) syncChanStates() error { // Ensure that all packets have been have been removed from the // link's mailbox. - if err := l.ackDownStreamPackets(true); err != nil { + if err := l.ackDownStreamPackets(); err != nil { return err } @@ -1493,12 +1493,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) { // removed from the circuit map before removing them from the link's mailbox, // otherwise it could be possible for some circuit to be missed if this link // flaps. -// -// The `forgive` flag allows this method to tolerate restarts, and ignores -// errors that could be caused by a previous circuit deletion. Under normal -// operation, this is set to false so that we would fail the link if we were -// unable to remove a circuit. -func (l *channelLink) ackDownStreamPackets(forgive bool) error { +func (l *channelLink) ackDownStreamPackets() error { // First, remove the downstream Add packets that were included in the // previous commitment signature. This will prevent the Adds from being // replayed if this link disconnects. @@ -1524,21 +1519,6 @@ func (l *channelLink) ackDownStreamPackets(forgive bool) error { case nil: // Successful deletion. - case ErrUnknownCircuit: - if forgive { - // After a restart, we may have already removed this - // circuit. Since it shouldn't be possible for a - // circuit to be closed by different htlcs, we assume - // this error signals that the whole batch was - // successfully removed. - l.warnf("forgiving unknown circuit error after " + - "attempting deletion, circuit was probably " + - "removed before shutting down.") - break - } - - return err - default: l.errorf("unable to delete %d circuits: %v", len(l.closedCircuits), err) @@ -1603,7 +1583,7 @@ func (l *channelLink) updateCommitTx() error { return err } - if err := l.ackDownStreamPackets(false); err != nil { + if err := l.ackDownStreamPackets(); err != nil { return err }