multi: rename FetchLightningNode
to FetchNode
This commit is contained in:
12 files changed
+41
-42
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
+13
-13
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-6
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+2
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user