graph/db: thread context through FetchNodeFeatures
This commit is contained in:
8 files changed
+30
-22
No files matched your search
+3
-1
@@ -1,6 +1,7 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
@@ -19,7 +20,8 @@ type Graph interface {
|
||||
reset func()) error
|
||||
|
||||
// FetchNodeFeatures returns the features of the given node.
|
||||
FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
||||
FetchNodeFeatures(ctx context.Context,
|
||||
nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
||||
}
|
||||
|
||||
// GraphSessionFactory can be used to gain access to a graphdb.NodeTraverser
|
||||
|
||||
@@ -2,6 +2,7 @@ package routing
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -221,8 +222,8 @@ func (m *mockGraph) sourceNode() route.Vertex {
|
||||
// fetchNodeFeatures returns the features of the given node.
|
||||
//
|
||||
// NOTE: Part of the Graph interface.
|
||||
func (m *mockGraph) FetchNodeFeatures(nodePub route.Vertex) (
|
||||
*lnwire.FeatureVector, error) {
|
||||
func (m *mockGraph) FetchNodeFeatures(_ context.Context,
|
||||
_ route.Vertex) (*lnwire.FeatureVector, error) {
|
||||
|
||||
return lnwire.EmptyFeatureVector(), nil
|
||||
}
|
||||
|
||||
+8
-3
@@ -3,6 +3,7 @@ package routing
|
||||
import (
|
||||
"bytes"
|
||||
"container/heap"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -621,7 +622,9 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
|
||||
features := r.DestFeatures
|
||||
if features == nil {
|
||||
var err error
|
||||
features, err = g.graph.FetchNodeFeatures(target)
|
||||
features, err = g.graph.FetchNodeFeatures(
|
||||
context.TODO(), target,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -1019,7 +1022,9 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
|
||||
}
|
||||
|
||||
// Fetch node features fresh from the graph.
|
||||
fromFeatures, err := g.graph.FetchNodeFeatures(node)
|
||||
fromFeatures, err := g.graph.FetchNodeFeatures(
|
||||
context.TODO(), node,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1349,7 +1354,7 @@ func findBlindedPaths(g Graph, target route.Vertex,
|
||||
return true, nil
|
||||
}
|
||||
|
||||
features, err := g.FetchNodeFeatures(node)
|
||||
features, err := g.FetchNodeFeatures(context.TODO(), node)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user