Skip to content

Commit 3648e20

Browse files
committed
mulit: fix linter
1 parent 20d6615 commit 3648e20

File tree

2 files changed

+51
-37
lines changed

2 files changed

+51
-37
lines changed

payments/db/payment_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ func genAttemptWithHash(t *testing.T, attemptID uint64,
418418

419419
// genInfo generates a payment creation info and the corresponding preimage.
420420
func genInfo(t *testing.T) (*PaymentCreationInfo, lntypes.Preimage, error) {
421-
422421
preimage, _, err := genPreimageAndHash(t)
423422
if err != nil {
424423
return nil, preimage, err
@@ -2392,14 +2391,10 @@ func TestQueryPayments(t *testing.T) {
23922391
"got %v", expectedTotal,
23932392
querySlice.TotalCount)
23942393
}
2395-
} else {
2396-
// When CountTotal is false, TotalCount should
2397-
// be 0.
2398-
if querySlice.TotalCount != 0 {
2399-
t.Errorf("expected total count 0 when "+
2400-
"CountTotal=false, got %v",
2401-
querySlice.TotalCount)
2402-
}
2394+
} else if querySlice.TotalCount != 0 {
2395+
t.Errorf("expected total count 0 when "+
2396+
"CountTotal=false, got %v",
2397+
querySlice.TotalCount)
24032398
}
24042399
})
24052400
}

payments/db/sql_store.go

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ func (s *SQLStore) DeletePayment(paymentHash lntypes.Hash,
628628
// Be careful to not use s.db here, because we are in a
629629
// transaction, is there a way to make this more secure?
630630
return db.DeletePayment(ctx, fetchPayment.Payment.ID)
631-
632631
}, func() {
633632
})
634633
if err != nil {
@@ -746,10 +745,12 @@ func (s *SQLStore) InitPayment(paymentHash lntypes.Hash,
746745
intentIDParam = sqldb.SQLInt64(*intentID)
747746
}
748747

748+
timeCreated := paymentCreationInfo.CreationTime.UTC()
749+
749750
err = db.InsertPayment(ctx, sqlc.InsertPaymentParams{
750751
IntentID: intentIDParam,
751752
AmountMsat: int64(paymentCreationInfo.Value),
752-
CreatedAt: paymentCreationInfo.CreationTime.UTC(),
753+
CreatedAt: timeCreated,
753754
PaymentIdentifier: paymentHash[:],
754755
})
755756
if err != nil {
@@ -760,9 +761,11 @@ func (s *SQLStore) InitPayment(paymentHash lntypes.Hash,
760761
// We need to fetch the payment we just inserted to get its ID
761762
insertedPayment, err := db.FetchPayment(ctx, paymentHash[:])
762763
if err != nil {
763-
return fmt.Errorf("failed to fetch inserted payment: %w", err)
764+
return fmt.Errorf("failed to fetch inserted "+
765+
"payment: %w", err)
764766
}
765767

768+
//nolint:ll
766769
for key, value := range paymentCreationInfo.FirstHopCustomRecords {
767770
err = db.InsertPaymentFirstHopCustomRecord(ctx,
768771
sqlc.InsertPaymentFirstHopCustomRecordParams{
@@ -811,26 +814,31 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
811814
// Insert the per-hop custom records
812815
if len(hop.CustomRecords) > 0 {
813816
for key, value := range hop.CustomRecords {
814-
err = db.InsertPaymentHopCustomRecord(ctx, sqlc.InsertPaymentHopCustomRecordParams{
815-
HopID: hopID,
816-
Key: int64(key),
817-
Value: value,
818-
})
817+
err = db.InsertPaymentHopCustomRecord(ctx,
818+
sqlc.InsertPaymentHopCustomRecordParams{
819+
HopID: hopID,
820+
Key: int64(key),
821+
Value: value,
822+
},
823+
)
819824
if err != nil {
820825
return fmt.Errorf("failed to insert "+
821-
"payment hop custom record: %w", err)
826+
"payment hop custom "+
827+
"records: %w", err)
822828
}
823829
}
824830
}
825831

826832
// Insert MPP data if present
827833
if hop.MPP != nil {
828834
paymentAddr := hop.MPP.PaymentAddr()
829-
err = db.InsertRouteHopMpp(ctx, sqlc.InsertRouteHopMppParams{
830-
HopID: hopID,
831-
PaymentAddr: paymentAddr[:],
832-
TotalMsat: int64(hop.MPP.TotalMsat()),
833-
})
835+
err = db.InsertRouteHopMpp(ctx,
836+
sqlc.InsertRouteHopMppParams{
837+
HopID: hopID,
838+
PaymentAddr: paymentAddr[:],
839+
TotalMsat: int64(hop.MPP.TotalMsat()),
840+
},
841+
)
834842
if err != nil {
835843
return fmt.Errorf("failed to insert "+
836844
"route hop MPP: %w", err)
@@ -841,11 +849,13 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
841849
if hop.AMP != nil {
842850
rootShare := hop.AMP.RootShare()
843851
setID := hop.AMP.SetID()
844-
err = db.InsertRouteHopAmp(ctx, sqlc.InsertRouteHopAmpParams{
845-
HopID: hopID,
846-
RootShare: rootShare[:],
847-
SetID: setID[:],
848-
})
852+
err = db.InsertRouteHopAmp(ctx,
853+
sqlc.InsertRouteHopAmpParams{
854+
HopID: hopID,
855+
RootShare: rootShare[:],
856+
SetID: setID[:],
857+
},
858+
)
849859
if err != nil {
850860
return fmt.Errorf("failed to insert "+
851861
"route hop AMP: %w", err)
@@ -856,15 +866,19 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
856866
if hop.EncryptedData != nil || hop.BlindingPoint != nil {
857867
var blindingPointBytes []byte
858868
if hop.BlindingPoint != nil {
869+
//nolint:ll
859870
blindingPointBytes = hop.BlindingPoint.SerializeCompressed()
860871
}
861872

862-
err = db.InsertRouteHopBlinded(ctx, sqlc.InsertRouteHopBlindedParams{
863-
HopID: hopID,
864-
EncryptedData: hop.EncryptedData,
865-
BlindingPoint: blindingPointBytes,
866-
BlindedPathTotalAmt: sqldb.SQLInt64(hop.TotalAmtMsat),
867-
})
873+
err = db.InsertRouteHopBlinded(ctx,
874+
//nolint:ll
875+
sqlc.InsertRouteHopBlindedParams{
876+
HopID: hopID,
877+
EncryptedData: hop.EncryptedData,
878+
BlindingPoint: blindingPointBytes,
879+
BlindedPathTotalAmt: sqldb.SQLInt64(hop.TotalAmtMsat),
880+
},
881+
)
868882
if err != nil {
869883
return fmt.Errorf("failed to insert "+
870884
"route hop blinded: %w", err)
@@ -934,8 +948,10 @@ func (s *SQLStore) RegisterAttempt(paymentHash lntypes.Hash,
934948
}
935949

936950
// Insert the route level first hop custom records.
951+
//nolint:ll
937952
for key, value := range attempt.Route.FirstHopWireCustomRecords {
938953
err = db.InsertPaymentAttemptFirstHopCustomRecord(ctx,
954+
//nolint:ll
939955
sqlc.InsertPaymentAttemptFirstHopCustomRecordParams{
940956
HtlcAttemptIndex: int64(attempt.AttemptID),
941957
Key: int64(key),
@@ -1057,6 +1073,7 @@ func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
10571073
}
10581074
}
10591075

1076+
//nolint:ll
10601077
err = db.FailAttempt(ctx, sqlc.FailAttemptParams{
10611078
AttemptIndex: int64(attemptID),
10621079
ResolutionTime: time.Now(),
@@ -1069,9 +1086,12 @@ func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
10691086
return fmt.Errorf("failed to fail attempt: %w", err)
10701087
}
10711088

1072-
mpPayment, err = s.fetchPaymentWithCompleteData(ctx, db, payment)
1089+
mpPayment, err = s.fetchPaymentWithCompleteData(
1090+
ctx, db, payment,
1091+
)
10731092
if err != nil {
1074-
return fmt.Errorf("failed to fetch payment with complete data: %w", err)
1093+
return fmt.Errorf("failed to fetch payment with"+
1094+
"complete data: %w", err)
10751095
}
10761096

10771097
return nil
@@ -1220,7 +1240,6 @@ func (s *SQLStore) DeletePayments(failedOnly, failedHtlcsOnly bool) (int,
12201240
ctx, s.cfg.QueryCfg, int64(-1), queryFunc,
12211241
extractCursor, processPayment,
12221242
)
1223-
12241243
}, func() {
12251244
numPayments = 0
12261245
})

0 commit comments

Comments
 (0)