Refactor Payment PR 3#9844
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
50f580b to
90108ed
Compare
8658c85 to
b308ed0
Compare
b308ed0 to
3a573e0
Compare
3a573e0 to
7faf0b0
Compare
8c5b919 to
4b08ee1
Compare
| "github.com/lightningnetwork/lnd/lntypes" | ||
| "github.com/lightningnetwork/lnd/lnutils" | ||
| "github.com/lightningnetwork/lnd/lnwire" | ||
| paymentsdb "github.com/lightningnetwork/lnd/payments/db" |
There was a problem hiding this comment.
nit: consider name it pdb for brevity?
There was a problem hiding this comment.
currently I prefer the longer name, but happy to change it in PR4, so that I don't end up in rebase hell. (most of the refactor PRs are ready so I would need to rebase everything all the time, so going to rename it after the last refactor for the whole series.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a significant refactoring that moves payment-related code from the channeldb package to a new, dedicated payments/db package. This is a great architectural improvement that enhances modularity and separation of concerns. The changes are extensive but appear to be consistently applied across the codebase. The introduction of a paymentsdb package with its own options and error types is a solid step forward. My review focuses on ensuring adherence to the project's style guide, particularly regarding line length, which I've found a few violations of.
99ed9d0 to
bbc8e63
Compare
bbc8e63 to
c010c72
Compare
47dca79 to
b51e82b
Compare
We add a context for the query method because the query method is part of the paymentDB interface and for the SQL case we will need the context for this method because the native SQL drivers demand one. So we add it for the kv implementation here as well so we can then make use of the new interface type.
We introduce a new package paymentsDB and start by moving the payment specifc errors from the channeldb package to the paymentsDB package. We also fix linter issues which showed up due to changing this code part.
Instead of the ChannelState struct we now use the kv backend interface for the payment kv database.
b51e82b to
4e0af2f
Compare
| // db is the underlying database implementation. | ||
| db kvdb.Backend | ||
|
|
||
| keepFailedPaymentAttempts bool |
| }, nil | ||
| } | ||
|
|
||
| var paymentsTopLevelBuckets = [][]byte{ |
There was a problem hiding this comment.
would be nice to add more docs, can do it in a later pr tho.
This Refactor commit starts moving payment related code into its own package.
It still keeps the KVPaymentDB implementation in the channeldb package. This will be moved to the payments package in the next PR.