htlcswitch: add new LinkFailureAction enum

In this commit, we add a new LinkFailureAction enum to take over the old
force close bool. Force closing isn't the only thing we might want to do
when we decide to fail the link, so this is a prep refactoring for an
upcoming change.
This commit is contained in:
Olaoluwa Osuntokun committed 2023-05-23 12:24:55 -07:00
1 parent 7dacf5edb9
commit cb5fc71659
4 files changed
+33 -21

No files matched your search

+9 -9
View File
@@ -1036,8 +1036,8 @@ func (l *channelLink) htlcManager() {
// storing the transaction in the db.
l.fail(
LinkFailureError{
code: ErrSyncError,
ForceClose: true,
code: ErrSyncError,
FailureAction: LinkFailureForceClose, // nolint:lll
},
"unable to synchronize channel "+
"states: %v", err,
@@ -1077,8 +1077,8 @@ func (l *channelLink) htlcManager() {
l.fail(
LinkFailureError{
code: ErrRecoveryError,
ForceClose: false,
code: ErrRecoveryError,
FailureAction: LinkFailureForceNone,
},
"unable to synchronize channel "+
"states: %v", err,
@@ -1782,8 +1782,8 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
if err := l.channel.ReceiveHTLCSettle(pre, idx); err != nil {
l.fail(
LinkFailureError{
code: ErrInvalidUpdate,
ForceClose: true,
code: ErrInvalidUpdate,
FailureAction: LinkFailureForceClose,
},
"unable to handle upstream settle HTLC: %v", err,
)
@@ -1947,9 +1947,9 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
}
l.fail(
LinkFailureError{
code: ErrInvalidCommitment,
ForceClose: true,
SendData: sendData,
code: ErrInvalidCommitment,
FailureAction: LinkFailureForceClose,
SendData: sendData,
},
"ChannelPoint(%v): unable to accept new "+
"commitment: %v",