multi: add abstraction for Router and SessionSource graph access
In this commit, we completely remove the Router's dependence on a Graph source that requires a `kvdb.RTx`. In so doing, we are more prepared for a future where the Graph source is backed by different DB structure such as pure SQL. The two areas affected here are: the ChannelRouter's graph access that it uses for pathfinding. And the SessionSource's graph access that it uses for payments. The ChannelRouter gets given a Graph and the SessionSource is given a GraphSessionFactory which it can use to create a new session. Behind the scenes, this will acquire a kvdb.RTx that will be used for calls to the Graph's `ForEachNodeChannel` method.
This commit is contained in:
11 files changed
+288
-128
No files matched your search
@@ -77,6 +77,7 @@ func (c *testCtx) RestartRouter(t *testing.T) {
|
||||
// With the chainView reset, we'll now re-create the router itself, and
|
||||
// start it.
|
||||
router, err := New(Config{
|
||||
RoutingGraph: newMockGraphSessionChanDB(c.graph),
|
||||
Graph: c.graph,
|
||||
Chain: c.chain,
|
||||
ChainView: c.chainView,
|
||||
@@ -140,7 +141,9 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
sourceNode, err := graphInstance.graph.SourceNode()
|
||||
require.NoError(t, err)
|
||||
sessionSource := &SessionSource{
|
||||
Graph: graphInstance.graph,
|
||||
GraphSessionFactory: newMockGraphSessionFactoryFromChanDB(
|
||||
graphInstance.graph,
|
||||
),
|
||||
SourceNode: sourceNode,
|
||||
GetLink: graphInstance.getLink,
|
||||
PathFindingConfig: pathFindingConfig,
|
||||
@@ -154,6 +157,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
}
|
||||
|
||||
router, err := New(Config{
|
||||
RoutingGraph: newMockGraphSessionChanDB(graphInstance.graph),
|
||||
Graph: graphInstance.graph,
|
||||
Chain: chain,
|
||||
ChainView: chainView,
|
||||
@@ -1763,6 +1767,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
|
||||
// Create new router with same graph database.
|
||||
router, err := New(Config{
|
||||
RoutingGraph: newMockGraphSessionChanDB(ctx.graph),
|
||||
Graph: ctx.graph,
|
||||
Chain: ctx.chain,
|
||||
ChainView: ctx.chainView,
|
||||
|
||||
Reference in new issue
Block a user