graph/db: thread context through to SourceNode
This commit is contained in:
12 files changed
+49
-32
No files matched your search
@@ -373,7 +373,7 @@ func TestSourceNode(t *testing.T) {
|
||||
|
||||
// Attempt to fetch the source node, this should return an error as the
|
||||
// source node hasn't yet been set.
|
||||
_, err := graph.SourceNode()
|
||||
_, err := graph.SourceNode(ctx)
|
||||
require.ErrorIs(t, err, ErrSourceNodeNotSet)
|
||||
|
||||
// Set the source node, this should insert the node into the
|
||||
@@ -382,7 +382,7 @@ func TestSourceNode(t *testing.T) {
|
||||
|
||||
// Retrieve the source node from the database, it should exactly match
|
||||
// the one we set above.
|
||||
sourceNode, err := graph.SourceNode()
|
||||
sourceNode, err := graph.SourceNode(ctx)
|
||||
require.NoError(t, err, "unable to fetch source node")
|
||||
compareNodes(t, testNode, sourceNode)
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ type V1Store interface { //nolint:interfacebloat
|
||||
// treated as the center node within a star-graph. This method may be
|
||||
// used to kick off a path finding algorithm in order to explore the
|
||||
// reachability of another node based off the source node.
|
||||
SourceNode() (*models.LightningNode, error)
|
||||
SourceNode(ctx context.Context) (*models.LightningNode, error)
|
||||
|
||||
// SetSourceNode sets the source node within the graph database. The
|
||||
// source node is to be used as the center of a star-graph within path
|
||||
|
||||
@@ -874,7 +874,9 @@ func (c *KVStore) ForEachNodeCacheable(cb func(route.Vertex,
|
||||
// as the center node within a star-graph. This method may be used to kick off
|
||||
// a path finding algorithm in order to explore the reachability of another
|
||||
// node based off the source node.
|
||||
func (c *KVStore) SourceNode() (*models.LightningNode, error) {
|
||||
func (c *KVStore) SourceNode(_ context.Context) (*models.LightningNode,
|
||||
error) {
|
||||
|
||||
var source *models.LightningNode
|
||||
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
|
||||
@@ -394,8 +394,8 @@ func (s *SQLStore) LookupAlias(pub *btcec.PublicKey) (string, error) {
|
||||
// node based off the source node.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) SourceNode() (*models.LightningNode, error) {
|
||||
ctx := context.TODO()
|
||||
func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode,
|
||||
error) {
|
||||
|
||||
var node *models.LightningNode
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
|
||||
Reference in new issue
Block a user