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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode, err := d.db.FetchLightningNode(ctx, vertex)
|
dbNode, err := d.db.FetchNode(ctx, vertex)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|||||||
@@ -2235,7 +2235,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context,
|
|||||||
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
|
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
|
||||||
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) (
|
|||||||
return &chanInfo, edge1, edge2, nil
|
return &chanInfo, edge1, edge2, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mockGraphSource) FetchLightningNode(_ context.Context,
|
func (r *mockGraphSource) FetchNode(_ context.Context,
|
||||||
nodePub route.Vertex) (*models.Node, error) {
|
nodePub route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
for _, node := range r.nodes {
|
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())
|
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
|
// key. graphdb.ErrGraphNodeNotFound is returned if the node doesn't exist
|
||||||
// within the graph.
|
// within the graph.
|
||||||
//
|
//
|
||||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
// 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) {
|
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
|
// 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
|
// Next, fetch the node from the database to ensure everything was
|
||||||
// serialized properly.
|
// serialized properly.
|
||||||
dbNode, err := graph.FetchLightningNode(ctx, testPub)
|
dbNode, err := graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err, "unable to locate node")
|
require.NoError(t, err, "unable to locate node")
|
||||||
|
|
||||||
_, exists, err := graph.HasLightningNode(ctx, dbNode.PubKeyBytes)
|
_, 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
|
// Finally, attempt to fetch the node again. This should fail as the
|
||||||
// node should have been deleted from the database.
|
// node should have been deleted from the database.
|
||||||
_, err = graph.FetchLightningNode(ctx, testPub)
|
_, err = graph.FetchNode(ctx, testPub)
|
||||||
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
||||||
|
|
||||||
// Now, we'll specifically test the updating of addresses of a node
|
// 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))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the empty addresses.
|
// Fetch the node and assert the empty addresses.
|
||||||
dbNode, err = graph.FetchLightningNode(ctx, testPub)
|
dbNode, err = graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
compareNodes(t, node, dbNode)
|
compareNodes(t, node, dbNode)
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
require.NoError(t, graph.AddNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// 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.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
require.Equal(t, expAddrs, dbNode.Addresses)
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
require.NoError(t, graph.AddNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// 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.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
require.Equal(t, expAddrs, dbNode.Addresses)
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
require.NoError(t, graph.AddNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// 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.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
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
|
// Next, fetch the node2 from the database to ensure everything was
|
||||||
// serialized properly.
|
// serialized properly.
|
||||||
dbNode1, err := graph.FetchLightningNode(ctx, pubKey1)
|
dbNode1, err := graph.FetchNode(ctx, pubKey1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
dbNode2, err := graph.FetchLightningNode(ctx, pubKey2)
|
dbNode2, err := graph.FetchNode(ctx, pubKey2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, exists, err := graph.HasLightningNode(ctx, dbNode1.PubKeyBytes)
|
_, 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
|
// Finally, attempt to fetch the node again. This should fail as the
|
||||||
// node should have been deleted from the database.
|
// node should have been deleted from the database.
|
||||||
_, err = graph.FetchLightningNode(ctx, testPub)
|
_, err = graph.FetchNode(ctx, testPub)
|
||||||
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
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
|
// Finally, we'll ensure that node3, the only fully unconnected node as
|
||||||
// properly deleted from the graph and not another node in its place.
|
// 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)
|
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
|
// Ensure that node1 was inserted as a full node, while node2 only has
|
||||||
// a shell node present.
|
// 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.NoError(t, err, "unable to fetch node1")
|
||||||
require.True(t, node1.HaveNodeAnnouncement)
|
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.NoError(t, err, "unable to fetch node2")
|
||||||
require.False(t, node2.HaveNodeAnnouncement)
|
require.False(t, node2.HaveNodeAnnouncement)
|
||||||
|
|
||||||
@@ -4470,7 +4470,7 @@ func TestLightningNodePersistence(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Read the node from disk.
|
// Read the node from disk.
|
||||||
diskNode, err := graph.FetchLightningNode(ctx, node.PubKeyBytes)
|
diskNode, err := graph.FetchNode(ctx, node.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Convert it back to a wire message.
|
// Convert it back to a wire message.
|
||||||
|
|||||||
@@ -112,11 +112,11 @@ type V1Store interface { //nolint:interfacebloat
|
|||||||
NodeUpdatesInHorizon(startTime,
|
NodeUpdatesInHorizon(startTime,
|
||||||
endTime time.Time) ([]models.Node, error)
|
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
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned.
|
// ErrGraphNodeNotFound is returned.
|
||||||
FetchLightningNode(ctx context.Context,
|
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
|
||||||
nodePub route.Vertex) (*models.Node, error)
|
error)
|
||||||
|
|
||||||
// HasLightningNode determines if the graph has a vertex identified by
|
// HasLightningNode determines if the graph has a vertex identified by
|
||||||
// the target node identity public key. If the node exists in the
|
// 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
|
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.
|
// We don't consider it an error if the graph is unaware of the node.
|
||||||
switch {
|
switch {
|
||||||
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
|
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
|
||||||
@@ -629,7 +629,7 @@ func (c *KVStore) fetchNodeFeatures(tx kvdb.RTx,
|
|||||||
node route.Vertex) (*lnwire.FeatureVector, error) {
|
node route.Vertex) (*lnwire.FeatureVector, error) {
|
||||||
|
|
||||||
// Fallback that uses the database.
|
// Fallback that uses the database.
|
||||||
targetNode, err := c.FetchLightningNodeTx(tx, node)
|
targetNode, err := c.fetchNodeTx(tx, node)
|
||||||
switch {
|
switch {
|
||||||
// If the node exists and has features, return them directly.
|
// If the node exists and has features, return them directly.
|
||||||
case err == nil:
|
case err == nil:
|
||||||
@@ -3043,20 +3043,20 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex,
|
|||||||
return nodeIsPublic, nil
|
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
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
||||||
// If none is provided, then a new one will be created.
|
// If none is provided, then a new one will be created.
|
||||||
func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
func (c *KVStore) fetchNodeTx(tx kvdb.RTx, nodePub route.Vertex) (*models.Node,
|
||||||
*models.Node, error) {
|
error) {
|
||||||
|
|
||||||
return c.fetchLightningNode(tx, nodePub)
|
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
|
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||||
// returned.
|
// returned.
|
||||||
func (c *KVStore) FetchLightningNode(_ context.Context,
|
func (c *KVStore) FetchNode(_ context.Context,
|
||||||
nodePub route.Vertex) (*models.Node, error) {
|
nodePub route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
return c.fetchLightningNode(nil, nodePub)
|
return c.fetchLightningNode(nil, nodePub)
|
||||||
|
|||||||
@@ -261,12 +261,12 @@ func (s *SQLStore) AddNode(ctx context.Context,
|
|||||||
return s.nodeScheduler.Execute(ctx, r)
|
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
|
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||||
// returned.
|
// returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// 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) {
|
pubKey route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
var node *models.Node
|
var node *models.Node
|
||||||
|
|||||||
+5
-6
@@ -83,11 +83,10 @@ type ChannelGraphSource interface {
|
|||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error)
|
*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
|
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
||||||
// doesn't exist within the graph.
|
// doesn't exist within the graph.
|
||||||
FetchLightningNode(context.Context,
|
FetchNode(context.Context, route.Vertex) (*models.Node, error)
|
||||||
route.Vertex) (*models.Node, error)
|
|
||||||
|
|
||||||
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
|
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
|
||||||
MarkZombieEdge(chanID uint64) error
|
MarkZombieEdge(chanID uint64) error
|
||||||
@@ -243,11 +242,11 @@ type DB interface {
|
|||||||
HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time,
|
HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time,
|
||||||
bool, error)
|
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
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned.
|
// ErrGraphNodeNotFound is returned.
|
||||||
FetchLightningNode(ctx context.Context,
|
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
|
||||||
nodePub route.Vertex) (*models.Node, error)
|
error)
|
||||||
|
|
||||||
// ForEachNodeChannel iterates through all channels of the given node,
|
// ForEachNodeChannel iterates through all channels of the given node,
|
||||||
// executing the passed callback with an edge info structure and the
|
// 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)
|
_, _, err = ctx.router.FindRoute(req)
|
||||||
require.NoError(t, err, "unable to find any routes")
|
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.NoError(t, err, "unable to fetch node")
|
||||||
|
|
||||||
require.Equal(t, n1.Alias, copy1.Alias)
|
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.NoError(t, err, "unable to fetch node")
|
||||||
|
|
||||||
require.Equal(t, n2.Alias, copy2.Alias)
|
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
|
// 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
|
// to this public key. If the node cannot be found, then an error will
|
||||||
// be returned.
|
// be returned.
|
||||||
node, err := graph.FetchLightningNode(ctx, pubKey)
|
node, err := graph.FetchNode(ctx, pubKey)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
||||||
return nil, status.Error(codes.NotFound, err.Error())
|
return nil, status.Error(codes.NotFound, err.Error())
|
||||||
@@ -8189,7 +8189,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
peer, err := r.server.graphDB.FetchLightningNode(ctx, vertex)
|
peer, err := r.server.graphDB.FetchNode(ctx, vertex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5208,7 +5208,7 @@ func (s *server) fetchNodeAdvertisedAddrs(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := s.graphDB.FetchLightningNode(ctx, vertex)
|
node, err := s.graphDB.FetchNode(ctx, vertex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user