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