From 330f697937e132d2dfc0b7013a8b549f781b9829 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 1 Sep 2025 14:24:35 +0200 Subject: [PATCH] graph: rename HasLightningNode to HasNode --- graph/builder.go | 2 +- graph/db/graph_test.go | 6 +++--- graph/db/interfaces.go | 5 ++--- graph/db/kv_store.go | 2 +- graph/db/sql_store.go | 4 ++-- graph/interfaces.go | 5 ++--- routing/router_test.go | 8 ++++---- rpcserver.go | 2 +- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/graph/builder.go b/graph/builder.go index bcbbdf44a..594093697 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -873,7 +873,7 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex, // node announcements, we will ignore such nodes. If we do know about // this node, check that this update brings info newer than what we // already have. - lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node) + lastUpdate, exists, err := b.cfg.Graph.HasNode(ctx, node) if err != nil { return fmt.Errorf("unable to query for the "+ "existence of node: %w", err) diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index e993c66bd..943e8df52 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -130,7 +130,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { dbNode, err := graph.FetchNode(ctx, testPub) require.NoError(t, err, "unable to locate node") - _, exists, err := graph.HasLightningNode(ctx, dbNode.PubKeyBytes) + _, exists, err := graph.HasNode(ctx, dbNode.PubKeyBytes) require.NoError(t, err) require.True(t, exists) @@ -301,7 +301,7 @@ func TestPartialNode(t *testing.T) { dbNode2, err := graph.FetchNode(ctx, pubKey2) require.NoError(t, err) - _, exists, err := graph.HasLightningNode(ctx, dbNode1.PubKeyBytes) + _, exists, err := graph.HasNode(ctx, dbNode1.PubKeyBytes) require.NoError(t, err) require.True(t, exists) @@ -315,7 +315,7 @@ func TestPartialNode(t *testing.T) { } compareNodes(t, expectedNode1, dbNode1) - _, exists, err = graph.HasLightningNode(ctx, dbNode2.PubKeyBytes) + _, exists, err = graph.HasNode(ctx, dbNode2.PubKeyBytes) require.NoError(t, err) require.True(t, exists) diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index 0a808ae55..f90c2da8a 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -118,13 +118,12 @@ type V1Store interface { //nolint:interfacebloat FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node, error) - // HasLightningNode determines if the graph has a vertex identified by + // HasNode determines if the graph has a vertex identified by // the target node identity public key. If the node exists in the // database, a timestamp of when the data for the node was lasted // updated is returned along with a true boolean. Otherwise, an empty // time.Time is returned with a false boolean. - HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time, - bool, error) + HasNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error) // IsPublicNode is a helper method that determines whether the node with // the given public key is seen as a public node in the graph from the diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 26c616820..165f51987 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -3124,7 +3124,7 @@ func (c *KVStore) fetchLightningNode(tx kvdb.RTx, // timestamp of when the data for the node was lasted updated is returned along // with a true boolean. Otherwise, an empty time.Time is returned with a false // boolean. -func (c *KVStore) HasLightningNode(_ context.Context, +func (c *KVStore) HasNode(_ context.Context, nodePub [33]byte) (time.Time, bool, error) { var ( diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 43b5941b4..02e1c1ae7 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -283,14 +283,14 @@ func (s *SQLStore) FetchNode(ctx context.Context, return node, nil } -// HasLightningNode determines if the graph has a vertex identified by the +// HasNode determines if the graph has a vertex identified by the // target node identity public key. If the node exists in the database, a // timestamp of when the data for the node was lasted updated is returned along // with a true boolean. Otherwise, an empty time.Time is returned with a false // boolean. // // NOTE: part of the V1Store interface. -func (s *SQLStore) HasLightningNode(ctx context.Context, +func (s *SQLStore) HasNode(ctx context.Context, pubKey [33]byte) (time.Time, bool, error) { var ( diff --git a/graph/interfaces.go b/graph/interfaces.go index b88a96411..ec4f42b79 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -234,13 +234,12 @@ type DB interface { UpdateEdgePolicy(ctx context.Context, edge *models.ChannelEdgePolicy, op ...batch.SchedulerOption) error - // HasLightningNode determines if the graph has a vertex identified by + // HasNode determines if the graph has a vertex identified by // the target node identity public key. If the node exists in the // database, a timestamp of when the data for the node was lasted // updated is returned along with a true boolean. Otherwise, an empty // time.Time is returned with a false boolean. - HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time, - bool, error) + HasNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error) // FetchNode attempts to look up a target node by its identity // public key. If the node isn't found in the database, then diff --git a/routing/router_test.go b/routing/router_test.go index 8408a6873..b811793d2 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -2718,11 +2718,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { copy(pub2[:], priv2.PubKey().SerializeCompressed()) // The two nodes we are about to add should not exist yet. - _, exists1, err := ctx.graph.HasLightningNode(ctxb, pub1) + _, exists1, err := ctx.graph.HasNode(ctxb, pub1) require.NoError(t, err, "unable to query graph") require.False(t, exists1) - _, exists2, err := ctx.graph.HasLightningNode(ctxb, pub2) + _, exists2, err := ctx.graph.HasNode(ctxb, pub2) require.NoError(t, err, "unable to query graph") require.False(t, exists2) @@ -2779,11 +2779,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { // After adding the edge between the two previously unknown nodes, they // should have been added to the graph. - _, exists1, err = ctx.graph.HasLightningNode(ctxb, pub1) + _, exists1, err = ctx.graph.HasNode(ctxb, pub1) require.NoError(t, err, "unable to query graph") require.True(t, exists1) - _, exists2, err = ctx.graph.HasLightningNode(ctxb, pub2) + _, exists2, err = ctx.graph.HasNode(ctxb, pub2) require.NoError(t, err, "unable to query graph") require.True(t, exists2) diff --git a/rpcserver.go b/rpcserver.go index c9ed796de..0c19c876a 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1783,7 +1783,7 @@ func (r *rpcServer) VerifyMessage(ctx context.Context, // // TODO(phlip9): Require valid nodes to have capital in active channels. graph := r.server.graphDB - _, active, err := graph.HasLightningNode(ctx, pub) + _, active, err := graph.HasNode(ctx, pub) if err != nil { return nil, fmt.Errorf("failed to query graph: %w", err) }