-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
graph+autopilot: remove autopilot
access to raw graphdb.ChannelGraph
#9480
base: master
Are you sure you want to change the base?
Conversation
And from various interfaces where it is not needed.
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 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
cc8e287
to
a42d65f
Compare
This is a pure code move commit where we move any code that is only ever used by tests to test files. Many of the calls to the graphdb.ChannelGraph pointer are only coming from tests code.
Introduce a new type for testing code so the main databaseChannelGraph type does to make various write calls to the `graphdb.ChannelGraph`.
In this commit, a new NodeTx interface is added which represents consistent access to a persisted models.LightningNode. The ForEachChannel method of the interface gives the caller access to the node's channels under the same read transaction (if any) that was used to fetch the node in the first place. The FetchNode method returns another NodeTx which again will have the same underlying read transaction. The main point of this interface is to provide this consistent access without needint to expose the `kvdb.RTx` type as a method parameter. This will then make it much easier in future to add new implementations of this interface that are backed by other databases (or RPC connections) where the `kvdb.RTx` type does not apply. We will make use of the new interface in the `autopilot` package in upcoming commits in order to remove the `autopilot`'s dependence on the pointer to the `*graphdb.ChannelGraph` which it has today.
Which passes a NodeTx to the call-back instead of a `kvdb.RTx`.
Define a new GraphSource interface that describes the access required by the autopilot server. Let its constructor take this interface instead of a raw pointer to the graphdb.ChannelGraph.
a42d65f
to
f0d4d08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🧇
@@ -30,6 +30,11 @@ type testGraph interface { | |||
addRandNode() (*btcec.PublicKey, error) | |||
} | |||
|
|||
type testDBGraph struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo in commit message: does to make
// NodeTx represents transaction object with an underlying node associated that | ||
// can be used to make further queries to the graph under the same transaction. | ||
// This is useful for consistency during graph traversal and queries. | ||
type NodeTx interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: given that this is a "read tx" we could reflect it in the name too, e.g. NodeRTx
. wdyt?
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error) error { | ||
|
||
return c.db.ForEachNodeChannelTx(c.tx, c.node.PubKeyBytes, | ||
func(_ kvdb.RTx, info *models.ChannelEdgeInfo, policy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/policy/policy1
In this PR, we remove the
autopilot
's direct access to thegraphdb.ChannelGraph
pointer and replaceit with a new
GraphSource
interface defined in theautopilot
package.This will allow us in future to more easily switch out the implementation provided to the autopilot code.
This is a pure refactor.