Skip to content

Commit 6c85629

Browse files
committed
channeldb: fix linter
1 parent 8861f7f commit 6c85629

File tree

2 files changed

+124
-52
lines changed

2 files changed

+124
-52
lines changed

channeldb/payments.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func (p *KVPaymentsDB) InitPayment(paymentHash lntypes.Hash,
406406
// are initializing a payment that was attempted earlier, but
407407
// left in a state where we could retry.
408408
err = bucket.DeleteNestedBucket(paymentHtlcsBucket)
409-
if err != nil && err != kvdb.ErrBucketNotFound {
409+
if err != nil && !errors.Is(err, kvdb.ErrBucketNotFound) {
410410
return err
411411
}
412412

@@ -431,6 +431,7 @@ func (p *KVPaymentsDB) DeleteFailedAttempts(hash lntypes.Hash) error {
431431
return err
432432
}
433433
}
434+
434435
return nil
435436
}
436437

@@ -454,6 +455,7 @@ func createPaymentIndexEntry(tx kvdb.RwTx, sequenceNumber []byte,
454455
}
455456

456457
indexes := tx.ReadWriteBucket(paymentsIndexBucket)
458+
457459
return indexes.Put(sequenceNumber, b.Bytes())
458460
}
459461

@@ -621,6 +623,7 @@ func (p *KVPaymentsDB) RegisterAttempt(paymentHash lntypes.Hash,
621623

622624
// Retrieve attempt info for the notification.
623625
payment, err = fetchPayment(bucket)
626+
624627
return err
625628
})
626629
if err != nil {
@@ -696,17 +699,25 @@ func (p *KVPaymentsDB) updateHtlcKey(paymentHash lntypes.Hash,
696699
return fmt.Errorf("htlcs bucket not found")
697700
}
698701

699-
if htlcsBucket.Get(htlcBucketKey(htlcAttemptInfoKey, aid)) == nil {
702+
attemptInfo := htlcsBucket.Get(
703+
htlcBucketKey(htlcAttemptInfoKey, aid),
704+
)
705+
if attemptInfo == nil {
700706
return fmt.Errorf("HTLC with ID %v not registered",
701707
attemptID)
702708
}
703709

704-
// Make sure the shard is not already failed or settled.
705-
if htlcsBucket.Get(htlcBucketKey(htlcFailInfoKey, aid)) != nil {
710+
failInfo := htlcsBucket.Get(
711+
htlcBucketKey(htlcFailInfoKey, aid),
712+
)
713+
if failInfo != nil {
706714
return ErrAttemptAlreadyFailed
707715
}
708716

709-
if htlcsBucket.Get(htlcBucketKey(htlcSettleInfoKey, aid)) != nil {
717+
settleInfo := htlcsBucket.Get(
718+
htlcBucketKey(htlcSettleInfoKey, aid),
719+
)
720+
if settleInfo != nil {
710721
return ErrAttemptAlreadySettled
711722
}
712723

@@ -718,6 +729,7 @@ func (p *KVPaymentsDB) updateHtlcKey(paymentHash lntypes.Hash,
718729

719730
// Retrieve attempt info for the notification.
720731
payment, err = fetchPayment(bucket)
732+
721733
return err
722734
})
723735
if err != nil {
@@ -746,7 +758,7 @@ func (p *KVPaymentsDB) Fail(paymentHash lntypes.Hash,
746758

747759
prefetchPayment(tx, paymentHash)
748760
bucket, err := fetchPaymentBucketUpdate(tx, paymentHash)
749-
if err == ErrPaymentNotInitiated {
761+
if errors.Is(err, ErrPaymentNotInitiated) {
750762
updateErr = ErrPaymentNotInitiated
751763
return nil
752764
} else if err != nil {
@@ -861,7 +873,6 @@ func fetchPaymentBucket(tx kvdb.RTx, paymentHash lntypes.Hash) (
861873
}
862874

863875
return bucket, nil
864-
865876
}
866877

867878
// fetchPaymentBucketUpdate is identical to fetchPaymentBucket, but it returns a
@@ -902,6 +913,7 @@ func (p *KVPaymentsDB) nextPaymentSequence() ([]byte, error) {
902913

903914
currPaymentSeq = paymentsBucket.Sequence()
904915
newUpperBound = currPaymentSeq + paymentSeqBlockSize
916+
905917
return paymentsBucket.SetSequence(newUpperBound)
906918
}, func() {}); err != nil {
907919
return nil, err
@@ -987,6 +999,7 @@ func (p *KVPaymentsDB) FetchInFlightPayments() ([]*MPPayment, error) {
987999
}
9881000

9891001
inFlights = append(inFlights, p)
1002+
9901003
return nil
9911004
})
9921005
}, func() {

0 commit comments

Comments
 (0)