mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
htlcswitch: fix linters
Fix a few linter errors - these were not caught before as they were configured to be ignored.
This commit is contained in:
@@ -1920,13 +1920,13 @@ func (l *channelLink) ackDownStreamPackets() error {
|
||||
// the link.
|
||||
func (l *channelLink) updateCommitTxOrFail(ctx context.Context) bool {
|
||||
err := l.updateCommitTx(ctx)
|
||||
switch err {
|
||||
switch {
|
||||
// No error encountered, success.
|
||||
case nil:
|
||||
case err == nil:
|
||||
|
||||
// A duplicate keystone error should be resolved and is not fatal, so
|
||||
// we won't send an Error message to the peer.
|
||||
case ErrDuplicateKeystone:
|
||||
case errors.Is(err, ErrDuplicateKeystone):
|
||||
l.failf(LinkFailureError{code: ErrCircuitError},
|
||||
"temporary circuit error: %v", err)
|
||||
return false
|
||||
@@ -3761,12 +3761,12 @@ func (l *channelLink) handleHtlcResolution(ctx context.Context,
|
||||
// No error, success.
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
switch err {
|
||||
|
||||
switch {
|
||||
// If the duplicate keystone error was encountered, fail back
|
||||
// gracefully.
|
||||
case ErrDuplicateKeystone:
|
||||
case errors.Is(err, ErrDuplicateKeystone):
|
||||
l.failf(
|
||||
LinkFailureError{
|
||||
code: ErrCircuitError,
|
||||
@@ -3935,9 +3935,9 @@ func (l *channelLink) resumeLink(ctx context.Context) error {
|
||||
// the channel is not pending, otherwise we should have no htlcs to
|
||||
// reforward.
|
||||
err = l.resolveFwdPkgs(ctx)
|
||||
switch err {
|
||||
switch {
|
||||
// No error was encountered, success.
|
||||
case nil:
|
||||
case err == nil:
|
||||
// With our link's in-memory state fully reconstructed, spawn a
|
||||
// goroutine to manage the reclamation of disk space occupied by
|
||||
// completed forwarding packages.
|
||||
@@ -3946,9 +3946,9 @@ func (l *channelLink) resumeLink(ctx context.Context) error {
|
||||
|
||||
return nil
|
||||
|
||||
// If the duplicate keystone error was encountered, we'll fail
|
||||
// without sending an Error message to the peer.
|
||||
case ErrDuplicateKeystone:
|
||||
// If the duplicate keystone error was encountered, we'll fail without
|
||||
// sending an Error message to the peer.
|
||||
case errors.Is(err, ErrDuplicateKeystone):
|
||||
l.failf(LinkFailureError{code: ErrCircuitError},
|
||||
"temporary circuit error: %v", err)
|
||||
|
||||
@@ -4264,10 +4264,10 @@ func (l *channelLink) processRemoteCommitSig(ctx context.Context,
|
||||
// then we'll examine the type of error. If it's an
|
||||
// InvalidCommitSigError, then we'll send a direct error.
|
||||
var sendData []byte
|
||||
switch err.(type) {
|
||||
case *lnwallet.InvalidCommitSigError:
|
||||
switch {
|
||||
case lnutils.ErrorAs[*lnwallet.InvalidCommitSigError](err):
|
||||
sendData = []byte(err.Error())
|
||||
case *lnwallet.InvalidHtlcSigError:
|
||||
case lnutils.ErrorAs[*lnwallet.InvalidHtlcSigError](err):
|
||||
sendData = []byte(err.Error())
|
||||
}
|
||||
l.failf(
|
||||
@@ -4315,9 +4315,9 @@ func (l *channelLink) processRemoteCommitSig(ctx context.Context,
|
||||
|
||||
// As soon as we are ready to send our next revocation, we can invoke
|
||||
// the incoming commit hooks.
|
||||
l.RWMutex.Lock()
|
||||
l.Lock()
|
||||
l.incomingCommitHooks.invoke()
|
||||
l.RWMutex.Unlock()
|
||||
l.Unlock()
|
||||
|
||||
err = l.cfg.Peer.SendMessage(false, nextRevocation)
|
||||
if err != nil {
|
||||
@@ -4378,11 +4378,11 @@ func (l *channelLink) processRemoteCommitSig(ctx context.Context,
|
||||
// Now that we have finished processing the incoming CommitSig and sent
|
||||
// out our RevokeAndAck, we invoke the flushHooks if the channel state
|
||||
// is clean.
|
||||
l.RWMutex.Lock()
|
||||
l.Lock()
|
||||
if l.channel.IsChannelClean() {
|
||||
l.flushHooks.invoke()
|
||||
}
|
||||
l.RWMutex.Unlock()
|
||||
l.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -4483,11 +4483,11 @@ func (l *channelLink) processRemoteRevokeAndAck(ctx context.Context,
|
||||
|
||||
// Now that we have finished processing the RevokeAndAck, we can invoke
|
||||
// the flushHooks if the channel state is clean.
|
||||
l.RWMutex.Lock()
|
||||
l.Lock()
|
||||
if l.channel.IsChannelClean() {
|
||||
l.flushHooks.invoke()
|
||||
}
|
||||
l.RWMutex.Unlock()
|
||||
l.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -4584,7 +4584,7 @@ func (l *channelLink) processLocalUpdateFulfillHTLC(ctx context.Context,
|
||||
// commitment state, it has already been cleaned up by a prior
|
||||
// response. We'll thus try to clean up any lingering state to
|
||||
// ensure we don't continue reforwarding.
|
||||
if _, ok := err.(lnwallet.ErrUnknownHtlcIndex); ok {
|
||||
if lnutils.ErrorAs[lnwallet.ErrUnknownHtlcIndex](err) {
|
||||
l.cleanupSpuriousResponse(pkt)
|
||||
}
|
||||
|
||||
@@ -4651,7 +4651,7 @@ func (l *channelLink) processLocalUpdateFailHTLC(ctx context.Context,
|
||||
// commitment state, it has already been cleaned up by a prior
|
||||
// response. We'll thus try to clean up any lingering state to
|
||||
// ensure we don't continue reforwarding.
|
||||
if _, ok := err.(lnwallet.ErrUnknownHtlcIndex); ok {
|
||||
if lnutils.ErrorAs[lnwallet.ErrUnknownHtlcIndex](err) {
|
||||
l.cleanupSpuriousResponse(pkt)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user