diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go index a68e0ebba..70f7e2b68 100644 --- a/autopilot/prefattach_test.go +++ b/autopilot/prefattach_test.go @@ -412,7 +412,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey, return nil, err } - dbNode, err := d.db.FetchLightningNode(ctx, vertex) + dbNode, err := d.db.FetchNode(ctx, vertex) switch { case errors.Is(err, graphdb.ErrGraphNodeNotFound): fallthrough diff --git a/discovery/gossiper.go b/discovery/gossiper.go index f24286ad9..047177d45 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -2235,7 +2235,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context, func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context, pubKey [33]byte) (*lnwire.NodeAnnouncement, error) { - node, err := d.cfg.Graph.FetchLightningNode(ctx, pubKey) + node, err := d.cfg.Graph.FetchNode(ctx, pubKey) if err != nil { return nil, err } diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index ea8a53aea..d0afa7d31 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -295,7 +295,7 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( return &chanInfo, edge1, edge2, nil } -func (r *mockGraphSource) FetchLightningNode(_ context.Context, +func (r *mockGraphSource) FetchNode(_ context.Context, nodePub route.Vertex) (*models.Node, error) { for _, node := range r.nodes { diff --git a/graph/builder.go b/graph/builder.go index d47f77cb1..bcbbdf44a 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -1257,15 +1257,15 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) ( return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64()) } -// FetchLightningNode attempts to look up a target node by its identity public +// FetchNode attempts to look up a target node by its identity public // key. graphdb.ErrGraphNodeNotFound is returned if the node doesn't exist // within the graph. // // NOTE: This method is part of the ChannelGraphSource interface. -func (b *Builder) FetchLightningNode(ctx context.Context, +func (b *Builder) FetchNode(ctx context.Context, node route.Vertex) (*models.Node, error) { - return b.cfg.Graph.FetchLightningNode(ctx, node) + return b.cfg.Graph.FetchNode(ctx, node) } // ForAllOutgoingChannels is used to iterate over all outgoing channels owned by diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 2889d9a8b..1b4afeab1 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -127,7 +127,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // Next, fetch the node from the database to ensure everything was // serialized properly. - dbNode, err := graph.FetchLightningNode(ctx, testPub) + dbNode, err := graph.FetchNode(ctx, testPub) require.NoError(t, err, "unable to locate node") _, exists, err := graph.HasLightningNode(ctx, dbNode.PubKeyBytes) @@ -163,7 +163,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // Finally, attempt to fetch the node again. This should fail as the // node should have been deleted from the database. - _, err = graph.FetchLightningNode(ctx, testPub) + _, err = graph.FetchNode(ctx, testPub) require.ErrorIs(t, err, ErrGraphNodeNotFound) // Now, we'll specifically test the updating of addresses of a node @@ -185,7 +185,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, graph.AddNode(ctx, node)) // Fetch the node and assert the empty addresses. - dbNode, err = graph.FetchLightningNode(ctx, testPub) + dbNode, err = graph.FetchNode(ctx, testPub) require.NoError(t, err) compareNodes(t, node, dbNode) @@ -214,7 +214,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, graph.AddNode(ctx, node)) // Fetch the node and assert the updated addresses. - dbNode, err = graph.FetchLightningNode(ctx, testPub) + dbNode, err = graph.FetchNode(ctx, testPub) require.NoError(t, err) require.Equal(t, expAddrs, dbNode.Addresses) @@ -235,7 +235,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, graph.AddNode(ctx, node)) // Fetch the node and assert the updated addresses. - dbNode, err = graph.FetchLightningNode(ctx, testPub) + dbNode, err = graph.FetchNode(ctx, testPub) require.NoError(t, err) require.Equal(t, expAddrs, dbNode.Addresses) @@ -248,7 +248,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, graph.AddNode(ctx, node)) // Fetch the node and assert the updated addresses. - dbNode, err = graph.FetchLightningNode(ctx, testPub) + dbNode, err = graph.FetchNode(ctx, testPub) require.NoError(t, err) require.Equal(t, expAddrs, dbNode.Addresses) @@ -296,9 +296,9 @@ func TestPartialNode(t *testing.T) { // Next, fetch the node2 from the database to ensure everything was // serialized properly. - dbNode1, err := graph.FetchLightningNode(ctx, pubKey1) + dbNode1, err := graph.FetchNode(ctx, pubKey1) require.NoError(t, err) - dbNode2, err := graph.FetchLightningNode(ctx, pubKey2) + dbNode2, err := graph.FetchNode(ctx, pubKey2) require.NoError(t, err) _, exists, err := graph.HasLightningNode(ctx, dbNode1.PubKeyBytes) @@ -336,7 +336,7 @@ func TestPartialNode(t *testing.T) { // Finally, attempt to fetch the node again. This should fail as the // node should have been deleted from the database. - _, err = graph.FetchLightningNode(ctx, testPub) + _, err = graph.FetchNode(ctx, testPub) require.ErrorIs(t, err, ErrGraphNodeNotFound) } @@ -3443,7 +3443,7 @@ func TestPruneGraphNodes(t *testing.T) { // Finally, we'll ensure that node3, the only fully unconnected node as // properly deleted from the graph and not another node in its place. - _, err := graph.FetchLightningNode(ctx, node3.PubKeyBytes) + _, err := graph.FetchNode(ctx, node3.PubKeyBytes) require.NotNil(t, err) } @@ -3469,11 +3469,11 @@ func TestAddChannelEdgeShellNodes(t *testing.T) { // Ensure that node1 was inserted as a full node, while node2 only has // a shell node present. - node1, err := graph.FetchLightningNode(ctx, node1.PubKeyBytes) + node1, err := graph.FetchNode(ctx, node1.PubKeyBytes) require.NoError(t, err, "unable to fetch node1") require.True(t, node1.HaveNodeAnnouncement) - node2, err = graph.FetchLightningNode(ctx, node2.PubKeyBytes) + node2, err = graph.FetchNode(ctx, node2.PubKeyBytes) require.NoError(t, err, "unable to fetch node2") require.False(t, node2.HaveNodeAnnouncement) @@ -4470,7 +4470,7 @@ func TestLightningNodePersistence(t *testing.T) { require.NoError(t, err) // Read the node from disk. - diskNode, err := graph.FetchLightningNode(ctx, node.PubKeyBytes) + diskNode, err := graph.FetchNode(ctx, node.PubKeyBytes) require.NoError(t, err) // Convert it back to a wire message. diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index f4a122d09..30fef2381 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -112,11 +112,11 @@ type V1Store interface { //nolint:interfacebloat NodeUpdatesInHorizon(startTime, endTime time.Time) ([]models.Node, error) - // FetchLightningNode attempts to look up a target node by its identity + // FetchNode attempts to look up a target node by its identity // public key. If the node isn't found in the database, then // ErrGraphNodeNotFound is returned. - FetchLightningNode(ctx context.Context, - nodePub route.Vertex) (*models.Node, error) + FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node, + error) // HasLightningNode determines if the graph has a vertex identified by // the target node identity public key. If the node exists in the diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 0f1535720..f57553a10 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -382,7 +382,7 @@ func (c *KVStore) AddrsForNode(ctx context.Context, return false, nil, err } - node, err := c.FetchLightningNode(ctx, pubKey) + node, err := c.FetchNode(ctx, pubKey) // We don't consider it an error if the graph is unaware of the node. switch { case err != nil && !errors.Is(err, ErrGraphNodeNotFound): @@ -629,7 +629,7 @@ func (c *KVStore) fetchNodeFeatures(tx kvdb.RTx, node route.Vertex) (*lnwire.FeatureVector, error) { // Fallback that uses the database. - targetNode, err := c.FetchLightningNodeTx(tx, node) + targetNode, err := c.fetchNodeTx(tx, node) switch { // If the node exists and has features, return them directly. case err == nil: @@ -3043,20 +3043,20 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex, return nodeIsPublic, nil } -// FetchLightningNodeTx attempts to look up a target node by its identity +// fetchNodeTx attempts to look up a target node by its identity // public key. If the node isn't found in the database, then // ErrGraphNodeNotFound is returned. An optional transaction may be provided. // If none is provided, then a new one will be created. -func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) ( - *models.Node, error) { +func (c *KVStore) fetchNodeTx(tx kvdb.RTx, nodePub route.Vertex) (*models.Node, + error) { return c.fetchLightningNode(tx, nodePub) } -// FetchLightningNode attempts to look up a target node by its identity public +// FetchNode attempts to look up a target node by its identity public // key. If the node isn't found in the database, then ErrGraphNodeNotFound is // returned. -func (c *KVStore) FetchLightningNode(_ context.Context, +func (c *KVStore) FetchNode(_ context.Context, nodePub route.Vertex) (*models.Node, error) { return c.fetchLightningNode(nil, nodePub) diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index ee985f78d..0bc19a3aa 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -261,12 +261,12 @@ func (s *SQLStore) AddNode(ctx context.Context, return s.nodeScheduler.Execute(ctx, r) } -// FetchLightningNode attempts to look up a target node by its identity public +// FetchNode attempts to look up a target node by its identity public // key. If the node isn't found in the database, then ErrGraphNodeNotFound is // returned. // // NOTE: part of the V1Store interface. -func (s *SQLStore) FetchLightningNode(ctx context.Context, +func (s *SQLStore) FetchNode(ctx context.Context, pubKey route.Vertex) (*models.Node, error) { var node *models.Node diff --git a/graph/interfaces.go b/graph/interfaces.go index 4b124f472..b88a96411 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -83,11 +83,10 @@ type ChannelGraphSource interface { *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) - // FetchLightningNode attempts to look up a target node by its identity + // FetchNode attempts to look up a target node by its identity // public key. channeldb.ErrGraphNodeNotFound is returned if the node // doesn't exist within the graph. - FetchLightningNode(context.Context, - route.Vertex) (*models.Node, error) + FetchNode(context.Context, route.Vertex) (*models.Node, error) // MarkZombieEdge marks the channel with the given ID as a zombie edge. MarkZombieEdge(chanID uint64) error @@ -243,11 +242,11 @@ type DB interface { HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error) - // FetchLightningNode attempts to look up a target node by its identity + // FetchNode attempts to look up a target node by its identity // public key. If the node isn't found in the database, then // ErrGraphNodeNotFound is returned. - FetchLightningNode(ctx context.Context, - nodePub route.Vertex) (*models.Node, error) + FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node, + error) // ForEachNodeChannel iterates through all channels of the given node, // executing the passed callback with an edge info structure and the diff --git a/routing/router_test.go b/routing/router_test.go index f8a8ae464..8408a6873 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -2908,12 +2908,12 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { _, _, err = ctx.router.FindRoute(req) require.NoError(t, err, "unable to find any routes") - copy1, err := ctx.graph.FetchLightningNode(ctxb, pub1) + copy1, err := ctx.graph.FetchNode(ctxb, pub1) require.NoError(t, err, "unable to fetch node") require.Equal(t, n1.Alias, copy1.Alias) - copy2, err := ctx.graph.FetchLightningNode(ctxb, pub2) + copy2, err := ctx.graph.FetchNode(ctxb, pub2) require.NoError(t, err, "unable to fetch node") require.Equal(t, n2.Alias, copy2.Alias) diff --git a/rpcserver.go b/rpcserver.go index 693e028ac..c9ed796de 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -7053,7 +7053,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, // With the public key decoded, attempt to fetch the node corresponding // to this public key. If the node cannot be found, then an error will // be returned. - node, err := graph.FetchLightningNode(ctx, pubKey) + node, err := graph.FetchNode(ctx, pubKey) switch { case errors.Is(err, graphdb.ErrGraphNodeNotFound): return nil, status.Error(codes.NotFound, err.Error()) @@ -8189,7 +8189,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context, return "", err } - peer, err := r.server.graphDB.FetchLightningNode(ctx, vertex) + peer, err := r.server.graphDB.FetchNode(ctx, vertex) if err != nil { return "", err } diff --git a/server.go b/server.go index 7b23662ad..83dd9a4d4 100644 --- a/server.go +++ b/server.go @@ -5208,7 +5208,7 @@ func (s *server) fetchNodeAdvertisedAddrs(ctx context.Context, return nil, err } - node, err := s.graphDB.FetchLightningNode(ctx, vertex) + node, err := s.graphDB.FetchNode(ctx, vertex) if err != nil { return nil, err }