graphdb: pass context to GraphSession
This commit is contained in:
9 files changed
+19
-16
No files matched your search
+2
-1
@@ -32,7 +32,8 @@ type GraphSessionFactory interface {
|
||||
// GraphSession will provide the call-back with access to a
|
||||
// graphdb.NodeTraverser instance which can be used to perform queries
|
||||
// against the channel graph.
|
||||
GraphSession(cb func(graph graphdb.NodeTraverser) error,
|
||||
GraphSession(ctx context.Context,
|
||||
cb func(graph graphdb.NodeTraverser) error,
|
||||
reset func()) error
|
||||
}
|
||||
|
||||
|
||||
@@ -234,8 +234,8 @@ func (m *mockGraph) FetchNodeFeatures(_ context.Context,
|
||||
// the channel graph.
|
||||
//
|
||||
// NOTE: Part of the GraphSessionFactory interface.
|
||||
func (m *mockGraph) GraphSession(cb func(graph graphdb.NodeTraverser) error,
|
||||
_ func()) error {
|
||||
func (m *mockGraph) GraphSession(_ context.Context,
|
||||
cb func(graph graphdb.NodeTraverser) error, _ func()) error {
|
||||
|
||||
return cb(m)
|
||||
}
|
||||
|
||||
@@ -3326,7 +3326,7 @@ func dbFindPath(graph *graphdb.VersionedGraph,
|
||||
}
|
||||
|
||||
var route []*unifiedEdge
|
||||
err = graph.GraphSession(func(graph graphdb.NodeTraverser) error {
|
||||
err = graph.GraphSession(ctx, func(graph graphdb.NodeTraverser) error {
|
||||
route, _, err = findPath(
|
||||
&graphParams{
|
||||
additionalEdges: additionalEdges,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
@@ -344,6 +345,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
||||
|
||||
for {
|
||||
err := p.graphSessFactory.GraphSession(
|
||||
context.TODO(),
|
||||
findPath, func() {
|
||||
path = nil
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -260,8 +261,8 @@ func (g *sessionGraph) sourceNode() route.Vertex {
|
||||
return route.Vertex{}
|
||||
}
|
||||
|
||||
func (g *sessionGraph) GraphSession(cb func(graph graphdb.NodeTraverser) error,
|
||||
_ func()) error {
|
||||
func (g *sessionGraph) GraphSession(_ context.Context,
|
||||
cb func(graph graphdb.NodeTraverser) error, _ func()) error {
|
||||
|
||||
return cb(g)
|
||||
}
|
||||
Reference in new issue
Block a user