Skip to content
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

multi: extend InvoiceDB methods with a context argument #8066

Merged
merged 3 commits into from
Oct 11, 2023

Conversation

bhandras
Copy link
Collaborator

@bhandras bhandras commented Oct 6, 2023

In preparation of the SQL based InvoiceDB implementation (draft in #8052) we add context to all InvoiceDB methods. This in turn results in some of the InvocieRegistry methods also requiring external context passed in.

Part of #6288

Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple prep PR, linter unhappy but otherwise lgtm.

Comment on lines 1030 to 1035
func (i *mockInvoiceRegistry) AddInvoice(invoice invoices.Invoice,
paymentHash lntypes.Hash) error {

_, err := i.registry.AddInvoice(&invoice, paymentHash)
_, err := i.registry.AddInvoice(
context.Background(), &invoice, paymentHash,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ctx not passed through here because AddInvoice isn't part of the InvoiceDatabase interface? Stands out reading this that this is the only place where we have context.Background().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I think I just forgot to fixup this call. Done.

@bhandras bhandras force-pushed the invoicedb-ctx branch 2 times, most recently from e4367e4 to de1dadd Compare October 9, 2023 08:34
@bhandras bhandras requested a review from carlaKC October 9, 2023 11:46
Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyforyongyu yyforyongyu added this to the v0.18.0 milestone Oct 11, 2023
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM🙏 Thanks for breaking down the PR!

This commit adds a context to InvoiceDB's methods. Along this refactor
we also extend InvoiceRegistry methods with contexts where it makes
sense. This change is essential to be able to provide kvdb and sqldb
implementations for InvoiceDB.
@bhandras bhandras added database Related to the database/storage of LND refactoring and removed no-changelog labels Oct 11, 2023
@guggero guggero merged commit ad5cd9c into lightningnetwork:master Oct 11, 2023
24 of 25 checks passed
@bhandras bhandras deleted the invoicedb-ctx branch October 11, 2023 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Related to the database/storage of LND refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants