htlcswitch/linkfailure: use whitelist for ShouldSendToPeer

This commit is contained in:
Conner Fromknecht 2020-04-14 10:51:06 -07:00
parent 6fca22be2b
commit a8977651cc
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -90,13 +90,23 @@ func (e LinkFailureError) Error() string {
// the link fails with this LinkFailureError. // the link fails with this LinkFailureError.
func (e LinkFailureError) ShouldSendToPeer() bool { func (e LinkFailureError) ShouldSendToPeer() bool {
switch e.code { switch e.code {
// If the failure is a result of the peer sending us an error, we don't
// have to respond with one.
case ErrRemoteError:
return false
// In all other cases we will attempt to send our peer an error message. // Since sending an error can lead some nodes to force close the
default: // channel, create a whitelist of the failures we want to send so that
// newly added error codes aren't automatically sent to the remote peer.
case
ErrInternalError,
ErrRemoteError,
ErrSyncError,
ErrInvalidUpdate,
ErrInvalidCommitment,
ErrInvalidRevocation,
ErrRecoveryError:
return true return true
// In all other cases we will not attempt to send our peer an error.
default:
return false
} }
} }