Skip to content

Commit a8451a9

Browse files
committed
mulit: fix linter
1 parent 369b373 commit a8451a9

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

lnrpc/routerrpc/router_backend.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,8 @@ func (r *RouterBackend) MarshallPayment(payment *paymentsdb.MPPayment) (
17451745
// If any of the htlcs have settled, extract a valid
17461746
// preimage.
17471747
if htlc.Settle != nil {
1748+
// For AMP payments all hashes will be different so we
1749+
// will depict the last htlc preimage.
17481750
preimage = htlc.Settle.Preimage
17491751
fee += htlc.Route.TotalFees()
17501752
}

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
@@ -2386,14 +2385,10 @@ func TestQueryPayments(t *testing.T) {
23862385
"got %v", expectedTotal,
23872386
querySlice.TotalCount)
23882387
}
2389-
} else {
2390-
// When CountTotal is false, TotalCount should
2391-
// be 0.
2392-
if querySlice.TotalCount != 0 {
2393-
t.Errorf("expected total count 0 when "+
2394-
"CountTotal=false, got %v",
2395-
querySlice.TotalCount)
2396-
}
2388+
} else if querySlice.TotalCount != 0 {
2389+
t.Errorf("expected total count 0 when "+
2390+
"CountTotal=false, got %v",
2391+
querySlice.TotalCount)
23972392
}
23982393
})
23992394
}

payments/db/sql_store.go

Lines changed: 29 additions & 20 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 {
@@ -813,26 +812,31 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
813812
// Insert the per-hop custom records
814813
if len(hop.CustomRecords) > 0 {
815814
for key, value := range hop.CustomRecords {
816-
err = db.InsertPaymentHopCustomRecord(ctx, sqlc.InsertPaymentHopCustomRecordParams{
817-
HopID: hopID,
818-
Key: int64(key),
819-
Value: value,
820-
})
815+
err = db.InsertPaymentHopCustomRecord(ctx,
816+
sqlc.InsertPaymentHopCustomRecordParams{
817+
HopID: hopID,
818+
Key: int64(key),
819+
Value: value,
820+
},
821+
)
821822
if err != nil {
822823
return fmt.Errorf("failed to insert "+
823-
"payment hop custom record: %w", err)
824+
"payment hop custom "+
825+
"records: %w", err)
824826
}
825827
}
826828
}
827829

828830
// Insert MPP data if present
829831
if hop.MPP != nil {
830832
paymentAddr := hop.MPP.PaymentAddr()
831-
err = db.InsertRouteHopMpp(ctx, sqlc.InsertRouteHopMppParams{
832-
HopID: hopID,
833-
PaymentAddr: paymentAddr[:],
834-
TotalMsat: int64(hop.MPP.TotalMsat()),
835-
})
833+
err = db.InsertRouteHopMpp(ctx,
834+
sqlc.InsertRouteHopMppParams{
835+
HopID: hopID,
836+
PaymentAddr: paymentAddr[:],
837+
TotalMsat: int64(hop.MPP.TotalMsat()),
838+
},
839+
)
836840
if err != nil {
837841
return fmt.Errorf("failed to insert "+
838842
"route hop MPP: %w", err)
@@ -843,11 +847,13 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
843847
if hop.AMP != nil {
844848
rootShare := hop.AMP.RootShare()
845849
setID := hop.AMP.SetID()
846-
err = db.InsertRouteHopAmp(ctx, sqlc.InsertRouteHopAmpParams{
847-
HopID: hopID,
848-
RootShare: rootShare[:],
849-
SetID: setID[:],
850-
})
850+
err = db.InsertRouteHopAmp(ctx,
851+
sqlc.InsertRouteHopAmpParams{
852+
HopID: hopID,
853+
RootShare: rootShare[:],
854+
SetID: setID[:],
855+
},
856+
)
851857
if err != nil {
852858
return fmt.Errorf("failed to insert "+
853859
"route hop AMP: %w", err)
@@ -946,6 +952,7 @@ func (s *SQLStore) RegisterAttempt(paymentHash lntypes.Hash,
946952

947953
for key, value := range attemptFirstHopCustomRecords {
948954
err = db.InsertPaymentAttemptFirstHopCustomRecord(ctx,
955+
//nolint:ll
949956
sqlc.InsertPaymentAttemptFirstHopCustomRecordParams{
950957
HtlcAttemptIndex: int64(attempt.AttemptID),
951958
Key: int64(key),
@@ -1081,9 +1088,12 @@ func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
10811088
return fmt.Errorf("failed to fail attempt: %w", err)
10821089
}
10831090

1084-
mpPayment, err = s.fetchPaymentWithCompleteData(ctx, db, payment)
1091+
mpPayment, err = s.fetchPaymentWithCompleteData(
1092+
ctx, db, payment,
1093+
)
10851094
if err != nil {
1086-
return fmt.Errorf("failed to fetch payment with complete data: %w", err)
1095+
return fmt.Errorf("failed to fetch payment with"+
1096+
"complete data: %w", err)
10871097
}
10881098

10891099
return nil
@@ -1232,7 +1242,6 @@ func (s *SQLStore) DeletePayments(failedOnly, failedHtlcsOnly bool) (int,
12321242
ctx, s.cfg.QueryCfg, int64(-1), queryFunc,
12331243
extractCursor, processPayment,
12341244
)
1235-
12361245
}, func() {
12371246
numPayments = 0
12381247
})

0 commit comments

Comments
 (0)