-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Part 2|*] Implement First Part for SQL Backend functions #10287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: elle-payment-sql-series-new
Are you sure you want to change the base?
Changes from 1 commit
18f03ec
c908b52
52d466f
353160c
fc4ce67
0849296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,13 @@ package paymentsdb | |
|
|
||
| import ( | ||
| "context" | ||
| "database/sql" | ||
| "errors" | ||
| "fmt" | ||
| "math" | ||
| "time" | ||
|
|
||
| "github.com/lightningnetwork/lnd/lntypes" | ||
| "github.com/lightningnetwork/lnd/lnwire" | ||
| "github.com/lightningnetwork/lnd/sqldb" | ||
| "github.com/lightningnetwork/lnd/sqldb/sqlc" | ||
|
|
@@ -474,3 +476,40 @@ func (s *SQLStore) QueryPayments(ctx context.Context, | |
| TotalCount: uint64(totalCount), | ||
| }, nil | ||
| } | ||
|
|
||
| // FetchPayment fetches the payment corresponding to the given payment | ||
| // hash. | ||
| // | ||
| // This is part of the DB interface. | ||
| func (s *SQLStore) FetchPayment(paymentHash lntypes.Hash) (*MPPayment, error) { | ||
| ctx := context.TODO() | ||
|
|
||
| var mpPayment *MPPayment | ||
|
|
||
| err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { | ||
| dbPayment, err := db.FetchPayment(ctx, paymentHash[:]) | ||
| if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
| return fmt.Errorf("failed to fetch payment: %w", err) | ||
| } | ||
|
|
||
| if errors.Is(err, sql.ErrNoRows) { | ||
| return ErrPaymentNotInitiated | ||
| } | ||
|
|
||
| mpPayment, err = s.fetchPaymentWithCompleteData( | ||
| ctx, db, dbPayment, | ||
| ) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to fetch payment with "+ | ||
| "complete data: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| }, func() { | ||
| }) | ||
|
Comment on lines
+508
to
+509
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sqldb.NoOpReset There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not addressed |
||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch payment: %w", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wrapping is redundant |
||
| } | ||
|
|
||
| return mpPayment, nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.