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.
This commit is contained in:
Conner Fromknecht 2018-08-18 19:35:20 -07:00
parent 78439416c0
commit 3fb6a310f8
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -585,7 +585,7 @@ func (l *channelLink) syncChanStates() error {
// Ensure that all packets have been have been removed from the // Ensure that all packets have been have been removed from the
// link's mailbox. // link's mailbox.
if err := l.ackDownStreamPackets(true); err != nil { if err := l.ackDownStreamPackets(); err != nil {
return err 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, // 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 // otherwise it could be possible for some circuit to be missed if this link
// flaps. // flaps.
// func (l *channelLink) ackDownStreamPackets() error {
// 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 {
// First, remove the downstream Add packets that were included in the // First, remove the downstream Add packets that were included in the
// previous commitment signature. This will prevent the Adds from being // previous commitment signature. This will prevent the Adds from being
// replayed if this link disconnects. // replayed if this link disconnects.
@ -1524,21 +1519,6 @@ func (l *channelLink) ackDownStreamPackets(forgive bool) error {
case nil: case nil:
// Successful deletion. // 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: default:
l.errorf("unable to delete %d circuits: %v", l.errorf("unable to delete %d circuits: %v",
len(l.closedCircuits), err) len(l.closedCircuits), err)
@ -1603,7 +1583,7 @@ func (l *channelLink) updateCommitTx() error {
return err return err
} }
if err := l.ackDownStreamPackets(false); err != nil { if err := l.ackDownStreamPackets(); err != nil {
return err return err
} }