multi: rename AddLightningNode methods
to AddNode
This commit is contained in:
14 files changed
+75
-75
No files matched your search
@@ -430,7 +430,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
graphNode.AddPubKey(pub)
|
graphNode.AddPubKey(pub)
|
||||||
err := d.db.AddLightningNode(
|
err := d.db.AddNode(
|
||||||
context.Background(), graphNode,
|
context.Background(), graphNode,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -460,7 +460,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
dbNode.AddPubKey(nodeKey)
|
dbNode.AddPubKey(nodeKey)
|
||||||
if err := d.db.AddLightningNode(
|
if err := d.db.AddNode(
|
||||||
context.Background(), dbNode,
|
context.Background(), dbNode,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -561,7 +561,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
dbNode.AddPubKey(nodeKey)
|
dbNode.AddPubKey(nodeKey)
|
||||||
err = d.db.AddLightningNode(context.Background(), dbNode)
|
err = d.db.AddNode(context.Background(), dbNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1003,7 +1003,7 @@ func (b *Builder) addNode(ctx context.Context, node *models.Node,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
|
if err := b.cfg.Graph.AddNode(ctx, node, op...); err != nil {
|
||||||
return fmt.Errorf("unable to add node %x to the "+
|
return fmt.Errorf("unable to add node %x to the "+
|
||||||
"graph: %w", node.PubKeyBytes, err)
|
"graph: %w", node.PubKeyBytes, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1475,7 +1475,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
|
|
||||||
// With the node fully parsed, add it as a vertex within the
|
// With the node fully parsed, add it as a vertex within the
|
||||||
// graph.
|
// graph.
|
||||||
if err := graph.AddLightningNode(ctx, dbNode); err != nil {
|
if err := graph.AddNode(ctx, dbNode); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1806,7 +1806,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
err = graph.SetSourceNode(ctx, dbNode)
|
err = graph.SetSourceNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else {
|
} else {
|
||||||
err := graph.AddLightningNode(ctx, dbNode)
|
err := graph.AddNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wgNodes.Done()
|
defer wgNodes.Done()
|
||||||
|
|
||||||
err := dest.AddLightningNode(ctx, node, batch.LazyAdd())
|
err := dest.AddNode(ctx, node, batch.LazyAdd())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
|
|||||||
+3
-3
@@ -266,16 +266,16 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information. Note that this method is expected to only be called to update an
|
// information. Note that this method is expected to only be called to update an
|
||||||
// already present node from a node announcement, or to insert a node found in a
|
// already present node from a node announcement, or to insert a node found in a
|
||||||
// channel update.
|
// channel update.
|
||||||
func (c *ChannelGraph) AddLightningNode(ctx context.Context,
|
func (c *ChannelGraph) AddNode(ctx context.Context,
|
||||||
node *models.Node, op ...batch.SchedulerOption) error {
|
node *models.Node, op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
err := c.V1Store.AddLightningNode(ctx, node, op...)
|
err := c.V1Store.AddNode(ctx, node, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-41
@@ -122,7 +122,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
// First, insert the node into the graph DB. This should succeed
|
// First, insert the node into the graph DB. This should succeed
|
||||||
// without any errors.
|
// without any errors.
|
||||||
node := nodeWithAddrs(testAddrs)
|
node := nodeWithAddrs(testAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
assertNodeInCache(t, graph, node, testFeatures)
|
assertNodeInCache(t, graph, node, testFeatures)
|
||||||
|
|
||||||
// Next, fetch the node from the database to ensure everything was
|
// Next, fetch the node from the database to ensure everything was
|
||||||
@@ -182,7 +182,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
|
|
||||||
// Add the node without any addresses.
|
// Add the node without any addresses.
|
||||||
node = nodeWithAddrs(nil)
|
node = nodeWithAddrs(nil)
|
||||||
require.NoError(t, graph.AddLightningNode(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.FetchLightningNode(ctx, testPub)
|
||||||
@@ -211,7 +211,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testOpaqueAddr,
|
testOpaqueAddr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(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.FetchLightningNode(ctx, testPub)
|
||||||
@@ -232,7 +232,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testIPV6Addr,
|
testIPV6Addr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(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.FetchLightningNode(ctx, testPub)
|
||||||
@@ -245,7 +245,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testOnionV3Addr,
|
testOnionV3Addr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(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.FetchLightningNode(ctx, testPub)
|
||||||
@@ -353,7 +353,7 @@ func TestAliasLookup(t *testing.T) {
|
|||||||
|
|
||||||
// Add the node to the graph's database, this should also insert an
|
// Add the node to the graph's database, this should also insert an
|
||||||
// entry into the alias index for this node.
|
// entry into the alias index for this node.
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, testNode))
|
require.NoError(t, graph.AddNode(ctx, testNode))
|
||||||
|
|
||||||
// Next, attempt to lookup the alias. The alias should exactly match
|
// Next, attempt to lookup the alias. The alias should exactly match
|
||||||
// the one which the test node was assigned.
|
// the one which the test node was assigned.
|
||||||
@@ -824,12 +824,12 @@ func TestEdgeInfoUpdates(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
assertNodeInCache(t, graph, node1, testFeatures)
|
assertNodeInCache(t, graph, node1, testFeatures)
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
assertNodeInCache(t, graph, node2, testFeatures)
|
assertNodeInCache(t, graph, node2, testFeatures)
|
||||||
@@ -1595,7 +1595,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
|||||||
// Add each of the nodes into the graph, they should be inserted
|
// Add each of the nodes into the graph, they should be inserted
|
||||||
// without error.
|
// without error.
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over each node as returned by the graph, if all nodes are
|
// Iterate over each node as returned by the graph, if all nodes are
|
||||||
@@ -1788,7 +1788,7 @@ func TestGraphPruning(t *testing.T) {
|
|||||||
for i := 0; i < numNodes; i++ {
|
for i := 0; i < numNodes; i++ {
|
||||||
node := createTestVertex(t)
|
node := createTestVertex(t)
|
||||||
|
|
||||||
if err := graph.AddLightningNode(ctx, node); err != nil {
|
if err := graph.AddNode(ctx, node); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2039,11 +2039,11 @@ func TestChanUpdatesInHorizon(t *testing.T) {
|
|||||||
|
|
||||||
// We'll start by creating two nodes which will seed our test graph.
|
// We'll start by creating two nodes which will seed our test graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2212,7 +2212,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
|||||||
|
|
||||||
nodeAnns = append(nodeAnns, *nodeAnn)
|
nodeAnns = append(nodeAnns, *nodeAnn)
|
||||||
|
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, nodeAnn))
|
require.NoError(t, graph.AddNode(ctx, nodeAnn))
|
||||||
}
|
}
|
||||||
|
|
||||||
queryCases := []struct {
|
queryCases := []struct {
|
||||||
@@ -2384,11 +2384,11 @@ func TestFilterKnownChanIDs(t *testing.T) {
|
|||||||
|
|
||||||
// We'll start by creating two nodes which will seed our test graph.
|
// We'll start by creating two nodes which will seed our test graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2539,10 +2539,10 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
|
|||||||
graph := MakeTestGraph(t)
|
graph := MakeTestGraph(t)
|
||||||
|
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
|
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// We need to update the node's timestamp since this call to
|
// We need to update the node's timestamp since this call to
|
||||||
// SetSourceNode will trigger an upsert which will only be allowed if
|
// SetSourceNode will trigger an upsert which will only be allowed if
|
||||||
@@ -2830,10 +2830,10 @@ func TestFilterChannelRange(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
|
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// If we try to filter a channel range before we have any channels
|
// If we try to filter a channel range before we have any channels
|
||||||
// inserted, we should get an empty slice of results.
|
// inserted, we should get an empty slice of results.
|
||||||
@@ -3049,11 +3049,11 @@ func TestFetchChanInfos(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3151,11 +3151,11 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
|||||||
|
|
||||||
// Create two nodes.
|
// Create two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3256,11 +3256,11 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3401,15 +3401,15 @@ func TestPruneGraphNodes(t *testing.T) {
|
|||||||
// channel graph, at the end of the scenario, only two of these nodes
|
// channel graph, at the end of the scenario, only two of these nodes
|
||||||
// should still be in the graph.
|
// should still be in the graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node3 := createTestVertex(t)
|
node3 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node3); err != nil {
|
if err := graph.AddNode(ctx, node3); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3483,7 +3483,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
|
|||||||
require.ErrorIs(t, err, ErrEdgeAlreadyExist)
|
require.ErrorIs(t, err, ErrEdgeAlreadyExist)
|
||||||
|
|
||||||
// Show that updating the shell node to a full node record works.
|
// Show that updating the shell node to a full node record works.
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed
|
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed
|
||||||
@@ -3498,7 +3498,7 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
// We'll first populate our graph with a single node that will be
|
// We'll first populate our graph with a single node that will be
|
||||||
// removed shortly.
|
// removed shortly.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3591,7 +3591,7 @@ func TestNodeIsPublic(t *testing.T) {
|
|||||||
for _, graph := range graphs {
|
for _, graph := range graphs {
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
node.LastUpdate = nextUpdateTime()
|
node.LastUpdate = nextUpdateTime()
|
||||||
err := graph.AddLightningNode(ctx, node)
|
err := graph.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
for _, edge := range edges {
|
for _, edge := range edges {
|
||||||
@@ -3693,20 +3693,20 @@ func TestDisabledChannelIDs(t *testing.T) {
|
|||||||
|
|
||||||
// Create first node and add it to the graph.
|
// Create first node and add it to the graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create second node and add it to the graph.
|
// Create second node and add it to the graph.
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding a new channel edge to the graph.
|
// Adding a new channel edge to the graph.
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
node2.LastUpdate = nextUpdateTime()
|
node2.LastUpdate = nextUpdateTime()
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3785,13 +3785,13 @@ func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
|
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
if err := graph.AddChannelEdge(ctx, edgeInfo); err != nil {
|
if err := graph.AddChannelEdge(ctx, edgeInfo); err != nil {
|
||||||
@@ -4186,9 +4186,9 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// Create an edge and add it to the db.
|
// Create an edge and add it to the db.
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
@@ -4294,9 +4294,9 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
|||||||
graph.graphCache = nil
|
graph.graphCache = nil
|
||||||
|
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// Create an edge and add it to the db.
|
// Create an edge and add it to the db.
|
||||||
edgeInfo, e1, e2 := createChannelEdge(node1, node2)
|
edgeInfo, e1, e2 := createChannelEdge(node1, node2)
|
||||||
@@ -4466,7 +4466,7 @@ func TestLightningNodePersistence(t *testing.T) {
|
|||||||
node := models.NodeFromWireAnnouncement(na)
|
node := models.NodeFromWireAnnouncement(na)
|
||||||
|
|
||||||
// Persist the node to disk.
|
// Persist the node to disk.
|
||||||
err = graph.AddLightningNode(ctx, node)
|
err = graph.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Read the node from disk.
|
// Read the node from disk.
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ type NodeTraverser interface {
|
|||||||
type V1Store interface { //nolint:interfacebloat
|
type V1Store interface { //nolint:interfacebloat
|
||||||
NodeTraverser
|
NodeTraverser
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the
|
// AddNode adds a vertex/node to the graph database. If the
|
||||||
// node is not in the database from before, this will add a new,
|
// node is not in the database from before, this will add a new,
|
||||||
// unconnected one to the graph. If it is present from before, this will
|
// unconnected one to the graph. If it is present from before, this will
|
||||||
// update that node's information. Note that this method is expected to
|
// update that node's information. Note that this method is expected to
|
||||||
// only be called to update an already present node from a node
|
// only be called to update an already present node from a node
|
||||||
// announcement, or to insert a node found in a channel update.
|
// announcement, or to insert a node found in a channel update.
|
||||||
AddLightningNode(ctx context.Context, node *models.Node,
|
AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// AddrsForNode returns all known addresses for the target node public
|
// AddrsForNode returns all known addresses for the target node public
|
||||||
|
|||||||
@@ -980,7 +980,7 @@ func (c *KVStore) SetSourceNode(_ context.Context,
|
|||||||
}, func() {})
|
}, func() {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information. Note that this method is expected to only be called to update an
|
// information. Note that this method is expected to only be called to update an
|
||||||
@@ -988,7 +988,7 @@ func (c *KVStore) SetSourceNode(_ context.Context,
|
|||||||
// channel update.
|
// channel update.
|
||||||
//
|
//
|
||||||
// TODO(roasbeef): also need sig of announcement.
|
// TODO(roasbeef): also need sig of announcement.
|
||||||
func (c *KVStore) AddLightningNode(ctx context.Context,
|
func (c *KVStore) AddNode(ctx context.Context,
|
||||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
r := &batch.Request[kvdb.RwTx]{
|
r := &batch.Request[kvdb.RwTx]{
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
var err error
|
var err error
|
||||||
switch obj := object.(type) {
|
switch obj := object.(type) {
|
||||||
case *models.Node:
|
case *models.Node:
|
||||||
err = db.AddLightningNode(ctx, obj)
|
err = db.AddNode(ctx, obj)
|
||||||
case *models.ChannelEdgeInfo:
|
case *models.ChannelEdgeInfo:
|
||||||
err = db.AddChannelEdge(ctx, obj)
|
err = db.AddChannelEdge(ctx, obj)
|
||||||
case *models.ChannelEdgePolicy:
|
case *models.ChannelEdgePolicy:
|
||||||
@@ -939,8 +939,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestMigration(t, populateKV, dbState{
|
runTestMigration(t, populateKV, dbState{
|
||||||
@@ -978,8 +978,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert both channels into the KV store.
|
// Insert both channels into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c1))
|
require.NoError(t, db.AddChannelEdge(ctx, c1))
|
||||||
@@ -1032,8 +1032,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert the channel into the KV store.
|
// Insert the channel into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c))
|
require.NoError(t, db.AddChannelEdge(ctx, c))
|
||||||
@@ -1113,8 +1113,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert the channel into the KV store.
|
// Insert the channel into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c))
|
require.NoError(t, db.AddChannelEdge(ctx, c))
|
||||||
@@ -1371,7 +1371,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
|||||||
|
|
||||||
// Write the test objects to the kvdb store.
|
// Write the test objects to the kvdb store.
|
||||||
for _, node := range allNodes {
|
for _, node := range allNodes {
|
||||||
err := kvDB.AddLightningNode(ctx, node)
|
err := kvDB.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
|
|||||||
@@ -241,13 +241,13 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information.
|
// information.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) AddLightningNode(ctx context.Context,
|
func (s *SQLStore) AddNode(ctx context.Context,
|
||||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
r := &batch.Request[SQLQueries]{
|
r := &batch.Request[SQLQueries]{
|
||||||
|
|||||||
+2
-2
@@ -200,13 +200,13 @@ type DB interface {
|
|||||||
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
||||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the
|
// AddNode adds a vertex/node to the graph database. If the
|
||||||
// node is not in the database from before, this will add a new,
|
// node is not in the database from before, this will add a new,
|
||||||
// unconnected one to the graph. If it is present from before, this will
|
// unconnected one to the graph. If it is present from before, this will
|
||||||
// update that node's information. Note that this method is expected to
|
// update that node's information. Note that this method is expected to
|
||||||
// only be called to update an already present node from a node
|
// only be called to update an already present node from a node
|
||||||
// announcement, or to insert a node found in a channel update.
|
// announcement, or to insert a node found in a channel update.
|
||||||
AddLightningNode(ctx context.Context, node *models.Node,
|
AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ func (s *Server) ImportGraph(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := graphDB.AddLightningNode(ctx, node); err != nil {
|
if err := graphDB.AddNode(ctx, node); err != nil {
|
||||||
return nil, fmt.Errorf("unable to add node %v: %w",
|
return nil, fmt.Errorf("unable to add node %v: %w",
|
||||||
rpcNode.PubKey, err)
|
rpcNode.PubKey, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,14 +293,14 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
source = dbNode
|
source = dbNode
|
||||||
|
|
||||||
// If this is the source node, we don't have to call
|
// If this is the source node, we don't have to call
|
||||||
// AddLightningNode below since we will call
|
// AddNode below since we will call
|
||||||
// SetSourceNode later.
|
// SetSourceNode later.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// With the node fully parsed, add it as a vertex within the
|
// With the node fully parsed, add it as a vertex within the
|
||||||
// graph.
|
// graph.
|
||||||
if err := graph.AddLightningNode(ctx, dbNode); err != nil {
|
if err := graph.AddNode(ctx, dbNode); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,7 +584,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
err = graph.SetSourceNode(ctx, dbNode)
|
err = graph.SetSourceNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else {
|
} else {
|
||||||
err := graph.AddLightningNode(ctx, dbNode)
|
err := graph.AddNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2882,7 +2882,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
|
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
|
||||||
|
|
||||||
require.NoError(t, ctx.graph.AddLightningNode(ctxb, n1))
|
require.NoError(t, ctx.graph.AddNode(ctxb, n1))
|
||||||
|
|
||||||
n2 := &models.Node{
|
n2 := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
@@ -2895,7 +2895,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
copy(n2.PubKeyBytes[:], priv2.PubKey().SerializeCompressed())
|
copy(n2.PubKeyBytes[:], priv2.PubKey().SerializeCompressed())
|
||||||
|
|
||||||
require.NoError(t, ctx.graph.AddLightningNode(ctxb, n2))
|
require.NoError(t, ctx.graph.AddNode(ctxb, n2))
|
||||||
|
|
||||||
// Should still be able to find the route, and the info should be
|
// Should still be able to find the route, and the info should be
|
||||||
// updated.
|
// updated.
|
||||||
|
|||||||
Reference in new issue
Block a user