From c663a557c4121bf5968daf371b3b070f0778d7a2 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 1 Sep 2025 12:40:15 +0200 Subject: [PATCH] multi: rename models.LightningNode to models.Node --- autopilot/graph.go | 6 +-- autopilot/interface.go | 2 +- autopilot/prefattach_test.go | 8 +-- channeldb/db_test.go | 6 +-- discovery/gossiper_test.go | 8 +-- graph/builder.go | 8 +-- graph/builder_test.go | 10 ++-- graph/db/benchmark_test.go | 9 ++-- graph/db/graph.go | 2 +- graph/db/graph_test.go | 66 ++++++++++++------------ graph/db/interfaces.go | 14 ++--- graph/db/kv_store.go | 86 +++++++++++++++---------------- graph/db/models/node.go | 18 +++---- graph/db/notifications.go | 2 +- graph/db/sql_migration.go | 10 ++-- graph/db/sql_migration_test.go | 77 ++++++++++++++------------- graph/db/sql_store.go | 42 +++++++-------- graph/interfaces.go | 10 ++-- graph/notifications_test.go | 8 +-- lnrpc/devrpc/dev_server.go | 2 +- routing/pathfind_test.go | 8 +-- routing/payment_session_source.go | 4 +- routing/payment_session_test.go | 2 +- routing/router_test.go | 8 +-- rpcserver.go | 4 +- server.go | 6 +-- 26 files changed, 212 insertions(+), 214 deletions(-) diff --git a/autopilot/graph.go b/autopilot/graph.go index 5a1f8dceb..be6401522 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -48,7 +48,7 @@ func ChannelGraphFromDatabase(db GraphSource) ChannelGraph { } // type dbNode is a wrapper struct around a database transaction an -// channeldb.LightningNode. The wrapper method implement the autopilot.Node +// channeldb.Node. The wrapper method implement the autopilot.Node // interface. type dbNode struct { pub [33]byte @@ -84,7 +84,7 @@ func (d *dbNode) Addrs() []net.Addr { func (d *databaseChannelGraph) ForEachNode(ctx context.Context, cb func(context.Context, Node) error, reset func()) error { - return d.db.ForEachNode(ctx, func(n *models.LightningNode) error { + return d.db.ForEachNode(ctx, func(n *models.Node) error { // We'll skip over any node that doesn't have any advertised // addresses. As we won't be able to reach them to actually // open any channels. @@ -161,7 +161,7 @@ func ChannelGraphFromCachedDatabase(db GraphSource) ChannelGraph { } // dbNodeCached is a wrapper struct around a database transaction for a -// channeldb.LightningNode. The wrapper methods implement the autopilot.Node +// channeldb.Node. The wrapper methods implement the autopilot.Node // interface. type dbNodeCached struct { node route.Vertex diff --git a/autopilot/interface.go b/autopilot/interface.go index 9d9d0d1ca..215f92035 100644 --- a/autopilot/interface.go +++ b/autopilot/interface.go @@ -230,7 +230,7 @@ type GraphSource interface { // graph, executing the passed callback with each node encountered. If // the callback returns an error, then the transaction is aborted and // the iteration stops early. - ForEachNode(context.Context, func(*models.LightningNode) error, + ForEachNode(context.Context, func(*models.Node) error, func()) error // ForEachNodeCached is similar to ForEachNode, but it utilizes the diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go index 2d1c7d4a7..e50eda1ed 100644 --- a/autopilot/prefattach_test.go +++ b/autopilot/prefattach_test.go @@ -403,7 +403,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey, ctx := context.Background() - fetchNode := func(pub *btcec.PublicKey) (*models.LightningNode, error) { + fetchNode := func(pub *btcec.PublicKey) (*models.Node, error) { if pub != nil { vertex, err := route.NewVertexFromBytes( pub.SerializeCompressed(), @@ -417,7 +417,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey, case errors.Is(err, graphdb.ErrGraphNodeNotFound): fallthrough case errors.Is(err, graphdb.ErrGraphNotFound): - graphNode := &models.LightningNode{ + graphNode := &models.Node{ HaveNodeAnnouncement: true, Addresses: []net.Addr{&net.TCPAddr{ IP: bytes.Repeat( @@ -447,7 +447,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey, if err != nil { return nil, err } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, Addresses: []net.Addr{ &net.TCPAddr{ @@ -548,7 +548,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) { if err != nil { return nil, err } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, Addresses: []net.Addr{ &net.TCPAddr{ diff --git a/channeldb/db_test.go b/channeldb/db_test.go index 2dd799365..96017e262 100644 --- a/channeldb/db_test.go +++ b/channeldb/db_test.go @@ -807,11 +807,11 @@ func TestFetchPermTempPeer(t *testing.T) { ) } -func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode { +func createLightningNode(priv *btcec.PrivateKey) *models.Node { updateTime := rand.Int63() pub := priv.PubKey().SerializeCompressed() - n := &models.LightningNode{ + n := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: time.Unix(updateTime, 0), @@ -825,7 +825,7 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode { return n } -func createTestVertex(t *testing.T) *models.LightningNode { +func createTestVertex(t *testing.T) *models.Node { priv, err := btcec.NewPrivateKey() require.NoError(t, err) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 2e743257e..ea8a53aea 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -83,7 +83,7 @@ type mockGraphSource struct { bestHeight uint32 mu sync.Mutex - nodes []models.LightningNode + nodes []models.Node infos map[uint64]models.ChannelEdgeInfo edges map[uint64][]models.ChannelEdgePolicy zombies map[uint64][][33]byte @@ -109,7 +109,7 @@ func newMockRouter(t *testing.T, height uint32) *mockGraphSource { var _ graph.ChannelGraphSource = (*mockGraphSource)(nil) -func (r *mockGraphSource) AddNode(_ context.Context, node *models.LightningNode, +func (r *mockGraphSource) AddNode(_ context.Context, node *models.Node, _ ...batch.SchedulerOption) error { r.mu.Lock() @@ -206,7 +206,7 @@ func (r *mockGraphSource) AddProof(chanID lnwire.ShortChannelID, } func (r *mockGraphSource) ForEachNode( - func(node *models.LightningNode) error) error { + func(node *models.Node) error) error { return nil } @@ -296,7 +296,7 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( } func (r *mockGraphSource) FetchLightningNode(_ context.Context, - nodePub route.Vertex) (*models.LightningNode, error) { + nodePub route.Vertex) (*models.Node, error) { for _, node := range r.nodes { if bytes.Equal(nodePub[:], node.PubKeyBytes[:]) { diff --git a/graph/builder.go b/graph/builder.go index 08016dd69..4af7156ae 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -975,7 +975,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool { // be ignored. // // NOTE: This method is part of the ChannelGraphSource interface. -func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode, +func (b *Builder) AddNode(ctx context.Context, node *models.Node, op ...batch.SchedulerOption) error { err := b.addNode(ctx, node, op...) @@ -988,11 +988,11 @@ func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode, return nil } -// addNode does some basic checks on the given LightningNode against what we +// addNode does some basic checks on the given Node against what we // currently have persisted in the graph, and then adds it to the graph. If we // already know about the node, then we only update our DB if the new update // has a newer timestamp than the last one we received. -func (b *Builder) addNode(ctx context.Context, node *models.LightningNode, +func (b *Builder) addNode(ctx context.Context, node *models.Node, op ...batch.SchedulerOption) error { // Before we add the node to the database, we'll check to see if the @@ -1263,7 +1263,7 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) ( // // NOTE: This method is part of the ChannelGraphSource interface. func (b *Builder) FetchLightningNode(ctx context.Context, - node route.Vertex) (*models.LightningNode, error) { + node route.Vertex) (*models.Node, error) { return b.cfg.Graph.FetchLightningNode(ctx, node) } diff --git a/graph/builder_test.go b/graph/builder_test.go index 82a44300d..4c3df2272 100644 --- a/graph/builder_test.go +++ b/graph/builder_test.go @@ -97,7 +97,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) { ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath) pub := priv1.PubKey() - node := &models.LightningNode{ + node := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(123, 0), Addresses: testAddrs, @@ -1084,7 +1084,7 @@ func TestIsStaleNode(t *testing.T) { // With the node stub in the database, we'll add the fully node // announcement to the database. - n1 := &models.LightningNode{ + n1 := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: updateTimeStamp, Addresses: testAddrs, @@ -1392,7 +1392,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( privKeyMap := make(map[string]*btcec.PrivateKey) channelIDs := make(map[route.Vertex]map[route.Vertex]uint64) links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink) - var source *models.LightningNode + var source *models.Node // First we insert all the nodes within the graph as vertexes. for _, node := range g.Nodes { @@ -1401,7 +1401,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( return nil, err } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: testTime, @@ -1787,7 +1787,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, features = lnwire.EmptyFeatureVector() } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: testTime, diff --git a/graph/db/benchmark_test.go b/graph/db/benchmark_test.go index 611653d53..b1b7b8231 100644 --- a/graph/db/benchmark_test.go +++ b/graph/db/benchmark_test.go @@ -350,7 +350,7 @@ func TestPopulateDBs(t *testing.T) { countNodes := func(graph *ChannelGraph) int { numNodes := 0 err := graph.ForEachNode( - ctx, func(node *models.LightningNode) error { + ctx, func(node *models.Node) error { numNodes++ return nil @@ -580,7 +580,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) { } var wgNodes sync.WaitGroup - err := src.ForEachNode(ctx, func(node *models.LightningNode) error { + err := src.ForEachNode(ctx, func(node *models.Node) error { wgNodes.Add(1) go func() { defer wgNodes.Done() @@ -746,7 +746,7 @@ func BenchmarkGraphReadMethods(b *testing.B) { fn: func(b testing.TB, store V1Store) { err := store.ForEachNode( ctx, - func(_ *models.LightningNode) error { + func(_ *models.Node) error { // Increment the counter to // ensure the callback is doing // something. @@ -932,10 +932,9 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) { numChannels = 0 ) - //nolint:ll err := store.ForEachNode( ctx, - func(_ *models.LightningNode) error { + func(_ *models.Node) error { numNodes++ return nil diff --git a/graph/db/graph.go b/graph/db/graph.go index 7ad87ed27..3278df71d 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -273,7 +273,7 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool, // already present node from a node announcement, or to insert a node found in a // channel update. func (c *ChannelGraph) AddLightningNode(ctx context.Context, - node *models.LightningNode, op ...batch.SchedulerOption) error { + node *models.Node, op ...batch.SchedulerOption) error { err := c.V1Store.AddLightningNode(ctx, node, op...) if err != nil { diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 0d55ef625..4a0434029 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -69,9 +69,9 @@ var ( } ) -func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode { +func createLightningNode(priv *btcec.PrivateKey) *models.Node { pub := priv.PubKey().SerializeCompressed() - n := &models.LightningNode{ + n := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: nextUpdateTime(), @@ -85,7 +85,7 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode { return n } -func createTestVertex(t testing.TB) *models.LightningNode { +func createTestVertex(t testing.TB) *models.Node { t.Helper() priv, err := btcec.NewPrivateKey() @@ -94,7 +94,7 @@ func createTestVertex(t testing.TB) *models.LightningNode { return createLightningNode(priv) } -// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode. +// TestNodeInsertionAndDeletion tests the CRUD operations for a Node. func TestNodeInsertionAndDeletion(t *testing.T) { t.Parallel() ctx := t.Context() @@ -104,9 +104,9 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // We'd like to test basic insertion/deletion for vertexes from the // graph, so we'll create a test vertex to start with. timeStamp := int64(1232342) - nodeWithAddrs := func(addrs []net.Addr) *models.LightningNode { + nodeWithAddrs := func(addrs []net.Addr) *models.Node { timeStamp++ - return &models.LightningNode{ + return &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: time.Unix(timeStamp, 0), @@ -271,7 +271,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, err) } -// TestPartialNode checks that we can add and retrieve a LightningNode where +// TestPartialNode checks that we can add and retrieve a Node where // only the pubkey is known to the database. func TestPartialNode(t *testing.T) { t.Parallel() @@ -281,7 +281,7 @@ func TestPartialNode(t *testing.T) { // To insert a partial node, we need to add a channel edge that has // node keys for nodes we are not yet aware - var node1, node2 models.LightningNode + var node1, node2 models.Node copy(node1.PubKeyBytes[:], pubKey1Bytes) copy(node2.PubKeyBytes[:], pubKey2Bytes) @@ -307,7 +307,7 @@ func TestPartialNode(t *testing.T) { // The two nodes should match exactly! (with default values for // LastUpdate and db set to satisfy compareNodes()) - expectedNode1 := &models.LightningNode{ + expectedNode1 := &models.Node{ HaveNodeAnnouncement: false, LastUpdate: time.Unix(0, 0), PubKeyBytes: pubKey1, @@ -321,7 +321,7 @@ func TestPartialNode(t *testing.T) { // The two nodes should match exactly! (with default values for // LastUpdate and db set to satisfy compareNodes()) - expectedNode2 := &models.LightningNode{ + expectedNode2 := &models.Node{ HaveNodeAnnouncement: false, LastUpdate: time.Unix(0, 0), PubKeyBytes: pubKey2, @@ -484,7 +484,7 @@ func TestEdgeInsertionDeletion(t *testing.T) { } func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32, - node1, node2 *models.LightningNode) (models.ChannelEdgeInfo, + node1, node2 *models.Node) (models.ChannelEdgeInfo, lnwire.ShortChannelID) { shortChanID := lnwire.ShortChannelID{ @@ -724,7 +724,7 @@ func withSkipProofs() createEdgeOpt { } } -func createChannelEdge(node1, node2 *models.LightningNode, +func createChannelEdge(node1, node2 *models.Node, options ...createEdgeOpt) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy, *models.ChannelEdgePolicy) { @@ -982,7 +982,7 @@ func TestEdgePolicyCRUD(t *testing.T) { updateAndAssertPolicies() } -func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.LightningNode, +func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.Node, expectedFeatures *lnwire.FeatureVector) { // Let's check the internal view first. @@ -1335,7 +1335,7 @@ func TestForEachSourceNodeChannel(t *testing.T) { // Now, we'll use the ForEachSourceNodeChannel and assert that it // returns the expected data in the call-back. err := graph.ForEachSourceNodeChannel(ctx, func(chanPoint wire.OutPoint, - havePolicy bool, otherNode *models.LightningNode) error { + havePolicy bool, otherNode *models.Node) error { require.Contains(t, expectedSrcChans, chanPoint) expected := expectedSrcChans[chanPoint] @@ -1468,7 +1468,7 @@ func TestGraphTraversalCacheable(t *testing.T) { // Create a map of all nodes with the iteration we know works (because // it is tested in another test). nodeMap := make(map[route.Vertex]struct{}) - err := graph.ForEachNode(ctx, func(n *models.LightningNode) error { + err := graph.ForEachNode(ctx, func(n *models.Node) error { nodeMap[n.PubKeyBytes] = struct{}{} return nil @@ -1579,11 +1579,11 @@ func TestGraphCacheTraversal(t *testing.T) { } func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes, - numChannels int) (map[uint64]struct{}, []*models.LightningNode) { + numChannels int) (map[uint64]struct{}, []*models.Node) { ctx := t.Context() - nodes := make([]*models.LightningNode, numNodes) + nodes := make([]*models.Node, numNodes) nodeIndex := map[string]struct{}{} for i := 0; i < numNodes; i++ { node := createTestVertex(t) @@ -1600,7 +1600,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes, // Iterate over each node as returned by the graph, if all nodes are // reached, then the map created above should be empty. - err := graph.ForEachNode(ctx, func(n *models.LightningNode) error { + err := graph.ForEachNode(ctx, func(n *models.Node) error { delete(nodeIndex, n.Alias) return nil }, func() {}) @@ -1710,7 +1710,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) { func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) { numNodes := 0 err := graph.ForEachNode(t.Context(), - func(_ *models.LightningNode) error { + func(_ *models.Node) error { numNodes++ return nil @@ -1784,7 +1784,7 @@ func TestGraphPruning(t *testing.T) { // and enough edges to create a fully connected graph. The graph will // be rather simple, representing a straight line. const numNodes = 5 - graphNodes := make([]*models.LightningNode, numNodes) + graphNodes := make([]*models.Node, numNodes) for i := 0; i < numNodes; i++ { node := createTestVertex(t) @@ -2198,7 +2198,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) { // We'll create 10 node announcements, each with an update timestamp 10 // seconds after the other. const numNodes = 10 - nodeAnns := make([]models.LightningNode, 0, numNodes) + nodeAnns := make([]models.Node, 0, numNodes) for i := 0; i < numNodes; i++ { nodeAnn := createTestVertex(t) @@ -2219,7 +2219,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) { start time.Time end time.Time - resp []models.LightningNode + resp []models.Node }{ // If we query for a time range that's strictly below our set // of updates, then we'll get an empty result back. @@ -2857,7 +2857,7 @@ func TestFilterChannelRange(t *testing.T) { ) updateTimeSeed := time.Now().Unix() - maybeAddPolicy := func(chanID uint64, node *models.LightningNode, + maybeAddPolicy := func(chanID uint64, node *models.Node, node2 bool) time.Time { var chanFlags lnwire.ChanUpdateChanFlags @@ -3168,7 +3168,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { } // Ensure that channel is reported with unknown policies. - checkPolicies := func(node *models.LightningNode, expectedIn, + checkPolicies := func(node *models.Node, expectedIn, expectedOut bool) { calls := 0 @@ -3585,7 +3585,7 @@ func TestNodeIsPublic(t *testing.T) { // After creating all of our nodes and edges, we'll add them to each // participant's graph. - nodes := []*models.LightningNode{aliceNode, bobNode, carolNode} + nodes := []*models.Node{aliceNode, bobNode, carolNode} edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge} graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph} for _, graph := range graphs { @@ -3602,7 +3602,7 @@ func TestNodeIsPublic(t *testing.T) { // checkNodes is a helper closure that will be used to assert that the // given nodes are seen as public/private within the given graphs. - checkNodes := func(nodes []*models.LightningNode, + checkNodes := func(nodes []*models.Node, graphs []*ChannelGraph, public bool) { t.Helper() @@ -3645,7 +3645,7 @@ func TestNodeIsPublic(t *testing.T) { } } checkNodes( - []*models.LightningNode{aliceNode}, + []*models.Node{aliceNode}, []*ChannelGraph{bobGraph, carolGraph}, false, ) @@ -3676,7 +3676,7 @@ func TestNodeIsPublic(t *testing.T) { // With the modifications above, Bob should now be seen as a private // node from both Alice's and Carol's perspective. checkNodes( - []*models.LightningNode{bobNode}, + []*models.Node{bobNode}, []*ChannelGraph{aliceGraph, carolGraph}, false, ) @@ -3979,8 +3979,8 @@ func TestGraphZombieIndex(t *testing.T) { assertNumZombies(t, graph, 1) } -// compareNodes is used to compare two LightningNodes. -func compareNodes(t *testing.T, a, b *models.LightningNode) { +// compareNodes is used to compare two Nodes. +func compareNodes(t *testing.T, a, b *models.Node) { t.Helper() // Call the PubKey method for each node to ensure that the internal @@ -4046,7 +4046,7 @@ func compareEdgePolicies(a, b *models.ChannelEdgePolicy) error { return nil } -// TestLightningNodeSigVerification checks that we can use the LightningNode's +// TestLightningNodeSigVerification checks that we can use the Node's // pubkey to verify signatures. func TestLightningNodeSigVerification(t *testing.T) { t.Parallel() @@ -4068,7 +4068,7 @@ func TestLightningNodeSigVerification(t *testing.T) { t.Fatalf("signature doesn't check out") } - // Create a LightningNode from the same private key. + // Create a Node from the same private key. node := createLightningNode(priv) // And finally check that we can verify the same signature from the @@ -4442,7 +4442,7 @@ var testNodeAnn = "01012674c2e7ef68c73a086b7de2603f4ef1567358df84bb4edaa06c" + "80000000d0000000005cd2a001260706204c" // TestLightningNodePersistence takes a raw serialized node announcement -// message, converts it to our internal models.LightningNode type, persists it +// message, converts it to our internal models.Node type, persists it // to disk, reads it again and converts it back to a wire message and asserts // that the two messages are equal. func TestLightningNodePersistence(t *testing.T) { diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index 7f9b37008..934560b3b 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -38,7 +38,7 @@ type V1Store interface { //nolint:interfacebloat // update that node's 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 channel update. - AddLightningNode(ctx context.Context, node *models.LightningNode, + AddLightningNode(ctx context.Context, node *models.Node, op ...batch.SchedulerOption) error // AddrsForNode returns all known addresses for the target node public @@ -53,7 +53,7 @@ type V1Store interface { //nolint:interfacebloat // the channel and the channel peer's node information. ForEachSourceNodeChannel(ctx context.Context, cb func(chanPoint wire.OutPoint, havePolicy bool, - otherNode *models.LightningNode) error, + otherNode *models.Node) error, reset func()) error // ForEachNodeChannel iterates through all channels of the given node, @@ -87,7 +87,7 @@ type V1Store interface { //nolint:interfacebloat // graph, executing the passed callback with each node encountered. If // the callback returns an error, then the transaction is aborted and // the iteration stops early. - ForEachNode(ctx context.Context, cb func(*models.LightningNode) error, + ForEachNode(ctx context.Context, cb func(*models.Node) error, reset func()) error // ForEachNodeCacheable iterates through all the stored vertices/nodes @@ -110,13 +110,13 @@ type V1Store interface { //nolint:interfacebloat // by two nodes to quickly determine if they have the same set of up to // date node announcements. NodeUpdatesInHorizon(startTime, - endTime time.Time) ([]models.LightningNode, error) + endTime time.Time) ([]models.Node, error) // FetchLightningNode 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.LightningNode, error) + 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 @@ -327,13 +327,13 @@ type V1Store interface { //nolint:interfacebloat // treated as the center node within a star-graph. This method may be // used to kick off a path finding algorithm in order to explore the // reachability of another node based off the source node. - SourceNode(ctx context.Context) (*models.LightningNode, error) + SourceNode(ctx context.Context) (*models.Node, error) // SetSourceNode sets the source node within the graph database. The // source node is to be used as the center of a star-graph within path // finding algorithms. SetSourceNode(ctx context.Context, - node *models.LightningNode) error + node *models.Node) error // PruneTip returns the block height and hash of the latest block that // has been used to prune channels in the graph. Knowing the "prune tip" diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 1abe34ba4..15f347191 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -683,7 +683,7 @@ func (c *KVStore) ForEachNodeCached(ctx context.Context, withAddrs bool, // node, and construct a similar callback functiopn signature as the // main funcotin expects. return forEachNode(c.db, func(tx kvdb.RTx, - node *models.LightningNode) error { + node *models.Node) error { channels := make(map[uint64]*DirectedChannel) @@ -804,10 +804,10 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) { // // NOTE: this is part of the V1Store interface. func (c *KVStore) ForEachNode(_ context.Context, - cb func(*models.LightningNode) error, reset func()) error { + cb func(*models.Node) error, reset func()) error { return forEachNode(c.db, func(tx kvdb.RTx, - node *models.LightningNode) error { + node *models.Node) error { return cb(node) }, reset) @@ -821,7 +821,7 @@ func (c *KVStore) ForEachNode(_ context.Context, // TODO(roasbeef): add iterator interface to allow for memory efficient graph // traversal when graph gets mega. func forEachNode(db kvdb.Backend, - cb func(kvdb.RTx, *models.LightningNode) error, reset func()) error { + cb func(kvdb.RTx, *models.Node) error, reset func()) error { traversal := func(tx kvdb.RTx) error { // First grab the nodes bucket which stores the mapping from @@ -899,14 +899,14 @@ func (c *KVStore) ForEachNodeCacheable(_ context.Context, // as the center node within a star-graph. This method may be used to kick off // a path finding algorithm in order to explore the reachability of another // node based off the source node. -func (c *KVStore) SourceNode(_ context.Context) (*models.LightningNode, error) { +func (c *KVStore) SourceNode(_ context.Context) (*models.Node, error) { return sourceNode(c.db) } // sourceNode fetches the source node of the graph. The source node is treated // as the center node within a star-graph. -func sourceNode(db kvdb.Backend) (*models.LightningNode, error) { - var source *models.LightningNode +func sourceNode(db kvdb.Backend) (*models.Node, error) { + var source *models.Node err := kvdb.View(db, func(tx kvdb.RTx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. @@ -936,7 +936,7 @@ func sourceNode(db kvdb.Backend) (*models.LightningNode, error) { // node of the graph. The source node is treated as the center node within a // star-graph. This method may be used to kick off a path finding algorithm in // order to explore the reachability of another node based off the source node. -func sourceNodeWithTx(nodes kvdb.RBucket) (*models.LightningNode, error) { +func sourceNodeWithTx(nodes kvdb.RBucket) (*models.Node, error) { selfPub := nodes.Get(sourceKey) if selfPub == nil { return nil, ErrSourceNodeNotSet @@ -956,7 +956,7 @@ func sourceNodeWithTx(nodes kvdb.RBucket) (*models.LightningNode, error) { // node is to be used as the center of a star-graph within path finding // algorithms. func (c *KVStore) SetSourceNode(_ context.Context, - node *models.LightningNode) error { + node *models.Node) error { nodePubBytes := node.PubKeyBytes[:] @@ -989,7 +989,7 @@ func (c *KVStore) SetSourceNode(_ context.Context, // // TODO(roasbeef): also need sig of announcement. func (c *KVStore) AddLightningNode(ctx context.Context, - node *models.LightningNode, opts ...batch.SchedulerOption) error { + node *models.Node, opts ...batch.SchedulerOption) error { r := &batch.Request[kvdb.RwTx]{ Opts: batch.NewSchedulerOptions(opts...), @@ -1001,7 +1001,7 @@ func (c *KVStore) AddLightningNode(ctx context.Context, return c.nodeScheduler.Execute(ctx, r) } -func addLightningNode(tx kvdb.RwTx, node *models.LightningNode) error { +func addLightningNode(tx kvdb.RwTx, node *models.Node) error { nodes, err := tx.CreateTopLevelBucket(nodeBucket) if err != nil { return err @@ -1204,7 +1204,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx, _, node1Err := fetchLightningNode(nodes, edge.NodeKey1Bytes[:]) switch { case errors.Is(node1Err, ErrGraphNodeNotFound): - node1Shell := models.LightningNode{ + node1Shell := models.Node{ PubKeyBytes: edge.NodeKey1Bytes, HaveNodeAnnouncement: false, } @@ -1220,7 +1220,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx, _, node2Err := fetchLightningNode(nodes, edge.NodeKey2Bytes[:]) switch { case errors.Is(node2Err, ErrGraphNodeNotFound): - node2Shell := models.LightningNode{ + node2Shell := models.Node{ PubKeyBytes: edge.NodeKey2Bytes, HaveNodeAnnouncement: false, } @@ -2032,11 +2032,11 @@ type ChannelEdge struct { // Node1 is "node 1" in the channel. This is the node that would have // produced Policy1 if it exists. - Node1 *models.LightningNode + Node1 *models.Node // Node2 is "node 2" in the channel. This is the node that would have // produced Policy2 if it exists. - Node2 *models.LightningNode + Node2 *models.Node } // ChanUpdatesInHorizon returns all the known channel edges which have at least @@ -2199,9 +2199,9 @@ func (c *KVStore) ChanUpdatesInHorizon(startTime, // nodes to quickly determine if they have the same set of up to date node // announcements. func (c *KVStore) NodeUpdatesInHorizon(startTime, - endTime time.Time) ([]models.LightningNode, error) { + endTime time.Time) ([]models.Node, error) { - var nodesInHorizon []models.LightningNode + var nodesInHorizon []models.Node err := kvdb.View(c.db, func(tx kvdb.RTx) error { nodes := tx.ReadBucket(nodeBucket) @@ -3048,7 +3048,7 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex, // 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.LightningNode, error) { + *models.Node, error) { return c.fetchLightningNode(tx, nodePub) } @@ -3057,7 +3057,7 @@ func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) ( // key. If the node isn't found in the database, then ErrGraphNodeNotFound is // returned. func (c *KVStore) FetchLightningNode(_ context.Context, - nodePub route.Vertex) (*models.LightningNode, error) { + nodePub route.Vertex) (*models.Node, error) { return c.fetchLightningNode(nil, nodePub) } @@ -3067,9 +3067,9 @@ func (c *KVStore) FetchLightningNode(_ context.Context, // returned. An optional transaction may be provided. If none is provided, then // a new one will be created. func (c *KVStore) fetchLightningNode(tx kvdb.RTx, - nodePub route.Vertex) (*models.LightningNode, error) { + nodePub route.Vertex) (*models.Node, error) { - var node *models.LightningNode + var node *models.Node fetch := func(tx kvdb.RTx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. @@ -3287,7 +3287,7 @@ func (c *KVStore) ForEachNodeChannel(_ context.Context, nodePub route.Vertex, // peer's node information. func (c *KVStore) ForEachSourceNodeChannel(_ context.Context, cb func(chanPoint wire.OutPoint, havePolicy bool, - otherNode *models.LightningNode) error, reset func()) error { + otherNode *models.Node) error, reset func()) error { return kvdb.View(c.db, func(tx kvdb.RTx) error { nodes := tx.ReadBucket(nodeBucket) @@ -3343,13 +3343,13 @@ func (c *KVStore) forEachNodeChannelTx(tx kvdb.RTx, return nodeTraversal(tx, nodePub[:], c.db, cb, reset) } -// fetchOtherNode attempts to fetch the full LightningNode that's opposite of +// fetchOtherNode attempts to fetch the full Node that's opposite of // the target node in the channel. This is useful when one knows the pubkey of -// one of the nodes, and wishes to obtain the full LightningNode for the other +// one of the nodes, and wishes to obtain the full Node for the other // end of the channel. func (c *KVStore) fetchOtherNode(tx kvdb.RTx, channel *models.ChannelEdgeInfo, thisNodeKey []byte) ( - *models.LightningNode, error) { + *models.Node, error) { // Ensure that the node passed in is actually a member of the channel. var targetNodeBytes [33]byte @@ -3362,7 +3362,7 @@ func (c *KVStore) fetchOtherNode(tx kvdb.RTx, return nil, fmt.Errorf("node not participating in this channel") } - var targetNode *models.LightningNode + var targetNode *models.Node fetchNodeFunc := func(tx kvdb.RTx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. @@ -4019,7 +4019,7 @@ func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) ( } func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket, - node *models.LightningNode) error { + node *models.Node) error { var ( scratch [16]byte @@ -4148,11 +4148,11 @@ func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket, } func fetchLightningNode(nodeBucket kvdb.RBucket, - nodePub []byte) (models.LightningNode, error) { + nodePub []byte) (models.Node, error) { nodeBytes := nodeBucket.Get(nodePub) if nodeBytes == nil { - return models.LightningNode{}, ErrGraphNodeNotFound + return models.Node{}, ErrGraphNodeNotFound } nodeReader := bytes.NewReader(nodeBytes) @@ -4215,9 +4215,9 @@ func deserializeLightningNodeCacheable(r io.Reader) (route.Vertex, return pubKey, features, nil } -func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { +func deserializeLightningNode(r io.Reader) (models.Node, error) { var ( - node models.LightningNode + node models.Node scratch [8]byte err error ) @@ -4227,18 +4227,18 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { node.Features = lnwire.EmptyFeatureVector() if _, err := r.Read(scratch[:]); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } unix := int64(byteOrder.Uint64(scratch[:])) node.LastUpdate = time.Unix(unix, 0) if _, err := io.ReadFull(r, node.PubKeyBytes[:]); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } if _, err := r.Read(scratch[:2]); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } hasNodeAnn := byteOrder.Uint16(scratch[:2]) @@ -4257,27 +4257,27 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { // We did get a node announcement for this node, so we'll have the rest // of the data available. if err := binary.Read(r, byteOrder, &node.Color.R); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } if err := binary.Read(r, byteOrder, &node.Color.G); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } if err := binary.Read(r, byteOrder, &node.Color.B); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } node.Alias, err = wire.ReadVarString(r, 0) if err != nil { - return models.LightningNode{}, err + return models.Node{}, err } err = node.Features.Decode(r) if err != nil { - return models.LightningNode{}, err + return models.Node{}, err } if _, err := r.Read(scratch[:2]); err != nil { - return models.LightningNode{}, err + return models.Node{}, err } numAddresses := int(byteOrder.Uint16(scratch[:2])) @@ -4285,7 +4285,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { for i := 0; i < numAddresses; i++ { address, err := DeserializeAddr(r) if err != nil { - return models.LightningNode{}, err + return models.Node{}, err } addresses = append(addresses, address) } @@ -4293,7 +4293,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { node.AuthSigBytes, err = wire.ReadVarBytes(r, 0, 80, "sig") if err != nil { - return models.LightningNode{}, err + return models.Node{}, err } // We'll try and see if there are any opaque bytes left, if not, then @@ -4305,7 +4305,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { case errors.Is(err, io.ErrUnexpectedEOF): case errors.Is(err, io.EOF): case err != nil: - return models.LightningNode{}, err + return models.Node{}, err } if len(extraBytes) > 0 { diff --git a/graph/db/models/node.go b/graph/db/models/node.go index ee769ddb6..ba4437c0a 100644 --- a/graph/db/models/node.go +++ b/graph/db/models/node.go @@ -11,11 +11,11 @@ import ( "github.com/lightningnetwork/lnd/lnwire" ) -// LightningNode represents an individual vertex/node within the channel graph. +// Node represents an individual vertex/node within the channel graph. // A node is connected to other nodes by one or more channel edges emanating // from it. As the graph is directed, a node will also have an incoming edge // attached to it for each outgoing edge. -type LightningNode struct { +type Node struct { // PubKeyBytes is the raw bytes of the public key of the target node. PubKeyBytes [33]byte pubKey *btcec.PublicKey @@ -65,7 +65,7 @@ type LightningNode struct { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the pubkey if absolutely necessary. -func (l *LightningNode) PubKey() (*btcec.PublicKey, error) { +func (l *Node) PubKey() (*btcec.PublicKey, error) { if l.pubKey != nil { return l.pubKey, nil } @@ -84,19 +84,19 @@ func (l *LightningNode) PubKey() (*btcec.PublicKey, error) { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the signature if absolutely necessary. -func (l *LightningNode) AuthSig() (*ecdsa.Signature, error) { +func (l *Node) AuthSig() (*ecdsa.Signature, error) { return ecdsa.ParseSignature(l.AuthSigBytes) } // AddPubKey is a setter-link method that can be used to swap out the public // key for a node. -func (l *LightningNode) AddPubKey(key *btcec.PublicKey) { +func (l *Node) AddPubKey(key *btcec.PublicKey) { l.pubKey = key copy(l.PubKeyBytes[:], key.SerializeCompressed()) } // NodeAnnouncement retrieves the latest node announcement of the node. -func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, +func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, error) { if !l.HaveNodeAnnouncement { @@ -132,13 +132,13 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, return nodeAnn, nil } -// NodeFromWireAnnouncement creates a LightningNode instance from an +// NodeFromWireAnnouncement creates a Node instance from an // lnwire.NodeAnnouncement message. -func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *LightningNode { +func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *Node { timestamp := time.Unix(int64(msg.Timestamp), 0) features := lnwire.NewFeatureVector(msg.Features, lnwire.Features) - return &LightningNode{ + return &Node{ HaveNodeAnnouncement: true, LastUpdate: timestamp, Addresses: msg.Addresses, diff --git a/graph/db/notifications.go b/graph/db/notifications.go index 20f2f07f0..eecc38c27 100644 --- a/graph/db/notifications.go +++ b/graph/db/notifications.go @@ -382,7 +382,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange, // Any node announcement maps directly to a NetworkNodeUpdate struct. // No further data munging or db queries are required. - case *models.LightningNode: + case *models.Node: pubKey, err := m.PubKey() if err != nil { return err diff --git a/graph/db/sql_migration.go b/graph/db/sql_migration.go index b88518fd8..23b156179 100644 --- a/graph/db/sql_migration.go +++ b/graph/db/sql_migration.go @@ -137,7 +137,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig, // fetch the corresponding node object in the SQL store, and it will // then be compared against the original KVDB node object. batch := make( - map[int64]*models.LightningNode, cfg.MaxBatchSize, + map[int64]*models.Node, cfg.MaxBatchSize, ) // validateBatch validates that the batch of nodes in the 'batch' map @@ -226,7 +226,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig, // Clear the batch map for the next iteration. batch = make( - map[int64]*models.LightningNode, cfg.MaxBatchSize, + map[int64]*models.Node, cfg.MaxBatchSize, ) return nil @@ -235,7 +235,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig, // Loop through each node in the KV store and insert it into the SQL // database. err := forEachNode(kvBackend, func(_ kvdb.RTx, - node *models.LightningNode) error { + node *models.Node) error { pub := node.PubKeyBytes @@ -307,7 +307,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig, chunk = 0 skipped = 0 t0 = time.Now() - batch = make(map[int64]*models.LightningNode, cfg.MaxBatchSize) + batch = make(map[int64]*models.Node, cfg.MaxBatchSize) }) if err != nil { return fmt.Errorf("could not migrate nodes: %w", err) @@ -1371,7 +1371,7 @@ func forEachClosedSCID(db kvdb.Backend, // the migration to be idempotent and dont want to error out if we re-insert the // exact same node. func insertNodeSQLMig(ctx context.Context, db SQLQueries, - node *models.LightningNode) (int64, error) { + node *models.Node) (int64, error) { params := sqlc.InsertNodeMigParams{ Version: int16(ProtocolV1), diff --git a/graph/db/sql_migration_test.go b/graph/db/sql_migration_test.go index 90b2a8fd8..108be21a8 100644 --- a/graph/db/sql_migration_test.go +++ b/graph/db/sql_migration_test.go @@ -73,7 +73,7 @@ func TestMigrateGraphToSQL(t *testing.T) { var err error switch obj := object.(type) { - case *models.LightningNode: + case *models.Node: err = db.AddLightningNode(ctx, obj) case *models.ChannelEdgeInfo: err = db.AddChannelEdge(ctx, obj) @@ -118,11 +118,11 @@ func TestMigrateGraphToSQL(t *testing.T) { // A node with no node announcement. makeTestShellNode(t), // A node with an announcement but no addresses. - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.Addresses = nil }), // A node with all types of addresses. - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.Addresses = []net.Addr{ testAddr, testIPV4Addr, @@ -134,11 +134,11 @@ func TestMigrateGraphToSQL(t *testing.T) { } }), // No extra opaque data. - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.ExtraOpaqueData = nil }), // A node with no features. - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.Features = lnwire.EmptyFeatureVector() }), }, @@ -149,7 +149,7 @@ func TestMigrateGraphToSQL(t *testing.T) { { name: "source node", write: func(t *testing.T, db *KVStore, object any) { - node, ok := object.(*models.LightningNode) + node, ok := object.(*models.Node) require.True(t, ok) err := db.SetSourceNode(ctx, node) @@ -175,11 +175,11 @@ func TestMigrateGraphToSQL(t *testing.T) { // Insert some nodes. // - node count += 1 - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.PubKeyBytes = node1 }), // - node count += 1 - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.PubKeyBytes = node2 }), @@ -228,11 +228,11 @@ func TestMigrateGraphToSQL(t *testing.T) { // Insert some nodes. // - node count += 1 - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.PubKeyBytes = node1 }), // - node count += 1 - makeTestNode(t, func(n *models.LightningNode) { + makeTestNode(t, func(n *models.Node) { n.PubKeyBytes = node2 }), @@ -296,7 +296,7 @@ func TestMigrateGraphToSQL(t *testing.T) { require.NoError(t, err) switch obj := object.(type) { - case *models.LightningNode: + case *models.Node: err = db.SetSourceNode(ctx, obj) default: height, ok := obj.(uint32) @@ -312,7 +312,7 @@ func TestMigrateGraphToSQL(t *testing.T) { // The PruneGraph call requires that the source // node be set. So that is the first object // we will write. - &models.LightningNode{ + &models.Node{ HaveNodeAnnouncement: false, PubKeyBytes: testPub, }, @@ -455,14 +455,13 @@ func assertInSync(t *testing.T, kvDB *KVStore, sqlDB *SQLStore, // fetchAllNodes retrieves all nodes from the given store and returns them // sorted by their public key. -func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode { - nodes := make([]*models.LightningNode, 0) +func fetchAllNodes(t *testing.T, store V1Store) []*models.Node { + nodes := make([]*models.Node, 0) err := store.ForEachNode(t.Context(), - func(node *models.LightningNode) error { - - // Call PubKey to ensure the objects cached pubkey is set so that - // the objects can be compared as a whole. + func(node *models.Node) error { + // Call PubKey to ensure the objects cached pubkey is + // set so that the objects can be compared as a whole. _, err := node.PubKey() require.NoError(t, err) @@ -479,7 +478,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode { require.NoError(t, err) // Sort the nodes by their public key to ensure a consistent order. - slices.SortFunc(nodes, func(i, j *models.LightningNode) int { + slices.SortFunc(nodes, func(i, j *models.Node) int { return bytes.Compare(i.PubKeyBytes[:], j.PubKeyBytes[:]) }) @@ -487,7 +486,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode { } // fetchSourceNode retrieves the source node from the given store. -func fetchSourceNode(t *testing.T, store V1Store) *models.LightningNode { +func fetchSourceNode(t *testing.T, store V1Store) *models.Node { node, err := store.SourceNode(t.Context()) if errors.Is(err, ErrSourceNodeNotSet) { return nil @@ -670,13 +669,13 @@ func genPubKey(t require.TestingT) route.Vertex { } // testNodeOpt defines a functional option type that can be used to -// modify the attributes of a models.LightningNode crated by makeTestNode. -type testNodeOpt func(*models.LightningNode) +// modify the attributes of a models.Node crated by makeTestNode. +type testNodeOpt func(*models.Node) -// makeTestNode can be used to create a test models.LightningNode. The +// makeTestNode can be used to create a test models.Node. The // functional options can be used to modify the node's attributes. -func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode { - n := &models.LightningNode{ +func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.Node { + n := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSigBytes, LastUpdate: testTime, @@ -700,12 +699,12 @@ func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode { return n } -// makeTestShellNode creates a minimal models.LightningNode +// makeTestShellNode creates a minimal models.Node // that only contains the public key and no other attributes. func makeTestShellNode(t *testing.T, - opts ...testNodeOpt) *models.LightningNode { + opts ...testNodeOpt) *models.Node { - n := &models.LightningNode{ + n := &models.Node{ HaveNodeAnnouncement: false, PubKeyBytes: genPubKey(t), Features: testEmptyFeatures, @@ -934,7 +933,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) { // Make one valid node and one node with invalid TLV data. n1 := makeTestNode(t) - n2 := makeTestNode(t, func(n *models.LightningNode) { + n2 := makeTestNode(t, func(n *models.Node) { n.ExtraOpaqueData = invalidTLVData }) @@ -947,7 +946,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) { runTestMigration(t, populateKV, dbState{ // We expect only the valid node to be present in the // SQL db. - nodes: []*models.LightningNode{n1}, + nodes: []*models.Node{n1}, }) }) @@ -995,7 +994,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) { runTestMigration(t, populateKV, dbState{ // Both nodes will be present. - nodes: []*models.LightningNode{n1, n2}, + nodes: []*models.Node{n1, n2}, // We only expect the first channel and its policy to // be present in the SQL db. chans: chanSet{{ @@ -1056,7 +1055,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) { runTestMigration(t, populateKV, dbState{ // Both nodes will be present. - nodes: []*models.LightningNode{n1, n2}, + nodes: []*models.Node{n1, n2}, // The channel will be present, but only the // valid policy will be included in the SQL db. chans: chanSet{{ @@ -1132,7 +1131,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) { runTestMigration(t, populateKV, dbState{ // Both nodes will be present. - nodes: []*models.LightningNode{n1, n2}, + nodes: []*models.Node{n1, n2}, // The channel will be present, but only the // valid policy will be included in the SQL db. chans: chanSet{{ @@ -1205,7 +1204,7 @@ func runTestMigration(t *testing.T, populateKV func(t *testing.T, db *KVStore), // dbState describes the expected state of the SQLStore after a migration. type dbState struct { - nodes []*models.LightningNode + nodes []*models.Node chans chanSet closed []uint64 zombies []uint64 @@ -1294,7 +1293,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, // Keep track of all nodes that should be in the database. We may expect // more than just the ones we generated above if we have channels that // point to shell nodes. - allNodes := make(map[route.Vertex]*models.LightningNode) + allNodes := make(map[route.Vertex]*models.Node) var nodePubs []route.Vertex for _, node := range nodes { allNodes[node.PubKeyBytes] = node @@ -1333,7 +1332,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, } shellNode := makeTestShellNode( - t, func(node *models.LightningNode) { + t, func(node *models.Node) { node.PubKeyBytes = n }, ) @@ -1389,7 +1388,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, require.NoError(t, err) // Create a slice of all nodes. - var nodesSlice []*models.LightningNode + var nodesSlice []*models.Node for _, node := range allNodes { nodesSlice = append(nodesSlice, node) } @@ -1603,7 +1602,7 @@ func sortAddrs(addrs []net.Addr) { } // genRandomNode is a rapid generator for creating random lightning nodes. -func genRandomNode(t *rapid.T) *models.LightningNode { +func genRandomNode(t *rapid.T) *models.Node { // Generate a random alias that is valid. alias := lnwire.RandNodeAlias(t) @@ -1647,7 +1646,7 @@ func genRandomNode(t *rapid.T) *models.LightningNode { extraOpaqueData = nil } - node := &models.LightningNode{ + node := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: sigBytes, LastUpdate: randTime, diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index c53a0fe5c..6b0a829c6 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -248,7 +248,7 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries, // // NOTE: part of the V1Store interface. func (s *SQLStore) AddLightningNode(ctx context.Context, - node *models.LightningNode, opts ...batch.SchedulerOption) error { + node *models.Node, opts ...batch.SchedulerOption) error { r := &batch.Request[SQLQueries]{ Opts: batch.NewSchedulerOptions(opts...), @@ -267,9 +267,9 @@ func (s *SQLStore) AddLightningNode(ctx context.Context, // // NOTE: part of the V1Store interface. func (s *SQLStore) FetchLightningNode(ctx context.Context, - pubKey route.Vertex) (*models.LightningNode, error) { + pubKey route.Vertex) (*models.Node, error) { - var node *models.LightningNode + var node *models.Node err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { var err error _, node, err = getNodeByPubKey(ctx, s.cfg.QueryCfg, db, pubKey) @@ -489,10 +489,10 @@ func (s *SQLStore) LookupAlias(ctx context.Context, // node based off the source node. // // NOTE: part of the V1Store interface. -func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode, +func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node, error) { - var node *models.LightningNode + var node *models.Node err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { _, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1) if err != nil { @@ -517,7 +517,7 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode, // // NOTE: part of the V1Store interface. func (s *SQLStore) SetSourceNode(ctx context.Context, - node *models.LightningNode) error { + node *models.Node) error { return s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error { id, err := upsertNode(ctx, db, node) @@ -553,11 +553,11 @@ func (s *SQLStore) SetSourceNode(ctx context.Context, // // NOTE: This is part of the V1Store interface. func (s *SQLStore) NodeUpdatesInHorizon(startTime, - endTime time.Time) ([]models.LightningNode, error) { + endTime time.Time) ([]models.Node, error) { ctx := context.TODO() - var nodes []models.LightningNode + var nodes []models.Node err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { dbNodes, err := db.GetNodesByLastUpdateRange( ctx, sqlc.GetNodesByLastUpdateRangeParams{ @@ -571,7 +571,7 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime, err = forEachNodeInBatch( ctx, s.cfg.QueryCfg, db, dbNodes, - func(_ int64, node *models.LightningNode) error { + func(_ int64, node *models.Node) error { nodes = append(nodes, *node) return nil @@ -776,7 +776,7 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy, // NOTE: part of the V1Store interface. func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context, cb func(chanPoint wire.OutPoint, havePolicy bool, - otherNode *models.LightningNode) error, reset func()) error { + otherNode *models.Node) error, reset func()) error { return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { nodeID, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1) @@ -832,13 +832,13 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context, // // NOTE: part of the V1Store interface. func (s *SQLStore) ForEachNode(ctx context.Context, - cb func(node *models.LightningNode) error, reset func()) error { + cb func(node *models.Node) error, reset func()) error { return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { return forEachNodePaginated( ctx, s.cfg.QueryCfg, db, ProtocolV1, func(_ context.Context, _ int64, - node *models.LightningNode) error { + node *models.Node) error { return cb(node) }, @@ -3201,7 +3201,7 @@ func updateChanEdgePolicy(ctx context.Context, tx SQLQueries, // getNodeByPubKey attempts to look up a target node by its public key. func getNodeByPubKey(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, - pubKey route.Vertex) (int64, *models.LightningNode, error) { + pubKey route.Vertex) (int64, *models.Node, error) { dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ @@ -3236,11 +3236,11 @@ func buildCacheableChannelInfo(scid []byte, capacity int64, node1Pub, } } -// buildNode constructs a LightningNode instance from the given database node +// buildNode constructs a Node instance from the given database node // record. The node's features, addresses and extra signed fields are also // fetched from the database and set on the node. func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, - dbNode sqlc.GraphNode) (*models.LightningNode, error) { + dbNode sqlc.GraphNode) (*models.Node, error) { data, err := batchLoadNodeData(ctx, cfg, db, []int64{dbNode.ID}) if err != nil { @@ -3251,12 +3251,12 @@ func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, return buildNodeWithBatchData(dbNode, data) } -// buildNodeWithBatchData builds a models.LightningNode instance +// buildNodeWithBatchData builds a models.Node instance // from the provided sqlc.GraphNode and batchNodeData. If the node does have // features/addresses/extra fields, then the corresponding fields are expected // to be present in the batchNodeData. func buildNodeWithBatchData(dbNode sqlc.GraphNode, - batchData *batchNodeData) (*models.LightningNode, error) { + batchData *batchNodeData) (*models.Node, error) { if dbNode.Version != int16(ProtocolV1) { return nil, fmt.Errorf("unsupported node version: %d", @@ -3266,7 +3266,7 @@ func buildNodeWithBatchData(dbNode sqlc.GraphNode, var pub [33]byte copy(pub[:], dbNode.PubKey) - node := &models.LightningNode{ + node := &models.Node{ PubKeyBytes: pub, Features: lnwire.EmptyFeatureVector(), LastUpdate: time.Unix(0, 0), @@ -3328,7 +3328,7 @@ func buildNodeWithBatchData(dbNode sqlc.GraphNode, // with the preloaded data, and executes the provided callback for each node. func forEachNodeInBatch(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, nodes []sqlc.GraphNode, - cb func(dbID int64, node *models.LightningNode) error) error { + cb func(dbID int64, node *models.Node) error) error { // Extract node IDs for batch loading. nodeIDs := make([]int64, len(nodes)) @@ -3382,7 +3382,7 @@ func getNodeFeatures(ctx context.Context, db SQLQueries, // then a new node is created. The node's features, addresses and extra TLV // types are also updated. The node's DB ID is returned. func upsertNode(ctx context.Context, db SQLQueries, - node *models.LightningNode) (int64, error) { + node *models.Node) (int64, error) { params := sqlc.UpsertNodeParams{ Version: int16(ProtocolV1), @@ -5064,7 +5064,7 @@ func batchLoadChannelPolicyExtrasHelper(ctx context.Context, func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, protocol ProtocolVersion, processNode func(context.Context, int64, - *models.LightningNode) error) error { + *models.Node) error) error { pageQueryFunc := func(ctx context.Context, lastID int64, limit int32) ([]sqlc.GraphNode, error) { diff --git a/graph/interfaces.go b/graph/interfaces.go index 5494db61a..e3d1c3cef 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -23,7 +23,7 @@ type ChannelGraphSource interface { // AddNode is used to add information about a node to the router // database. If the node with this pubkey is not present in an existing // channel, it will be ignored. - AddNode(ctx context.Context, node *models.LightningNode, + AddNode(ctx context.Context, node *models.Node, op ...batch.SchedulerOption) error // AddEdge is used to add edge/channel to the topology of the router, @@ -87,7 +87,7 @@ type ChannelGraphSource interface { // public key. channeldb.ErrGraphNodeNotFound is returned if the node // doesn't exist within the graph. FetchLightningNode(context.Context, - route.Vertex) (*models.LightningNode, error) + route.Vertex) (*models.Node, error) // MarkZombieEdge marks the channel with the given ID as a zombie edge. MarkZombieEdge(chanID uint64) error @@ -135,7 +135,7 @@ type DB interface { // treated as the center node within a star-graph. This method may be // used to kick off a path finding algorithm in order to explore the // reachability of another node based off the source node. - SourceNode(ctx context.Context) (*models.LightningNode, error) + SourceNode(ctx context.Context) (*models.Node, error) // DisabledChannelIDs returns the channel ids of disabled channels. // A channel is disabled when two of the associated ChanelEdgePolicies @@ -206,7 +206,7 @@ type DB interface { // update that node's 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 channel update. - AddLightningNode(ctx context.Context, node *models.LightningNode, + AddLightningNode(ctx context.Context, node *models.Node, op ...batch.SchedulerOption) error // AddChannelEdge adds a new (undirected, blank) edge to the graph @@ -247,7 +247,7 @@ type DB interface { // public key. If the node isn't found in the database, then // ErrGraphNodeNotFound is returned. FetchLightningNode(ctx context.Context, - nodePub route.Vertex) (*models.LightningNode, error) + 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/graph/notifications_test.go b/graph/notifications_test.go index fc7d4fb4d..32408424a 100644 --- a/graph/notifications_test.go +++ b/graph/notifications_test.go @@ -76,14 +76,14 @@ var ( } ) -func createTestNode(t *testing.T) *models.LightningNode { +func createTestNode(t *testing.T) *models.Node { updateTime := prand.Int63() priv, err := btcec.NewPrivateKey() require.NoError(t, err) pub := priv.PubKey().SerializeCompressed() - n := &models.LightningNode{ + n := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(updateTime, 0), Addresses: testAddrs, @@ -98,7 +98,7 @@ func createTestNode(t *testing.T) *models.LightningNode { } func randEdgePolicy(chanID *lnwire.ShortChannelID, - node *models.LightningNode) (*models.ChannelEdgePolicy, error) { + node *models.Node) (*models.ChannelEdgePolicy, error) { InboundFee := models.InboundFee{ Base: prand.Int31() * -1, @@ -676,7 +676,7 @@ func TestNodeUpdateNotification(t *testing.T) { t.Fatalf("unable to add node: %v", err) } - assertNodeNtfnCorrect := func(t *testing.T, ann *models.LightningNode, + assertNodeNtfnCorrect := func(t *testing.T, ann *models.Node, nodeUpdate *graphdb.NetworkNodeUpdate) { nodeKey, _ := ann.PubKey() diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index d25118864..9ec78a77c 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -226,7 +226,7 @@ func (s *Server) ImportGraph(ctx context.Context, var err error for _, rpcNode := range graph.Nodes { - node := &models.LightningNode{ + node := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix( int64(rpcNode.LastUpdate), 0, diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 6c23f794c..35ec47ebd 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -219,7 +219,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( privKeyMap := make(map[string]*btcec.PrivateKey) channelIDs := make(map[route.Vertex]map[route.Vertex]uint64) links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink) - var source *models.LightningNode + var source *models.Node // First we insert all the nodes within the graph as vertexes. for _, node := range g.Nodes { @@ -228,7 +228,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( return nil, err } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: testTime, @@ -565,7 +565,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, features = lnwire.EmptyFeatureVector() } - dbNode := &models.LightningNode{ + dbNode := &models.Node{ HaveNodeAnnouncement: true, AuthSigBytes: testSig.Serialize(), LastUpdate: testTime, @@ -1253,7 +1253,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) { dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes) require.NoError(t, err, "unable to parse public key from bytes") - doge := &models.LightningNode{} + doge := &models.Node{} doge.AddPubKey(dogePubKey) doge.Alias = "doge" copy(doge.PubKeyBytes[:], dogePubKeyBytes) diff --git a/routing/payment_session_source.go b/routing/payment_session_source.go index 5e4eb23d7..bc1088d7b 100644 --- a/routing/payment_session_source.go +++ b/routing/payment_session_source.go @@ -24,7 +24,7 @@ type SessionSource struct { GraphSessionFactory GraphSessionFactory // SourceNode is the graph's source node. - SourceNode *models.LightningNode + SourceNode *models.Node // GetLink is a method that allows querying the lower link layer // to determine the up to date available bandwidth at a prospective link @@ -102,7 +102,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) ( // we'll need to look at the next hint's start node. If // we've reached the end of the hints list, we can // assume we've reached the destination. - endNode := &models.LightningNode{} + endNode := &models.Node{} if i != len(routeHint)-1 { endNode.AddPubKey(routeHint[i+1].NodeID) } else { diff --git a/routing/payment_session_test.go b/routing/payment_session_test.go index ffe9d996c..12d8608a4 100644 --- a/routing/payment_session_test.go +++ b/routing/payment_session_test.go @@ -89,7 +89,7 @@ func TestUpdateAdditionalEdge(t *testing.T) { // Create a minimal test node using the private key priv1. pub := priv1.PubKey().SerializeCompressed() - testNode := &models.LightningNode{} + testNode := &models.Node{} copy(testNode.PubKeyBytes[:], pub) nodeID, err := testNode.PubKey() diff --git a/routing/router_test.go b/routing/router_test.go index acf7a5212..520a3e42e 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -183,7 +183,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T, return ctx } -func createTestNode() (*models.LightningNode, error) { +func createTestNode() (*models.Node, error) { updateTime := rand.Int63() priv, err := btcec.NewPrivateKey() @@ -192,7 +192,7 @@ func createTestNode() (*models.LightningNode, error) { } pub := priv.PubKey().SerializeCompressed() - n := &models.LightningNode{ + n := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(updateTime, 0), Addresses: testAddrs, @@ -2871,7 +2871,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { // Now check that we can update the node info for the partial node // without messing up the channel graph. - n1 := &models.LightningNode{ + n1 := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(123, 0), Addresses: testAddrs, @@ -2884,7 +2884,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { require.NoError(t, ctx.graph.AddLightningNode(ctxb, n1)) - n2 := &models.LightningNode{ + n2 := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(123, 0), Addresses: testAddrs, diff --git a/rpcserver.go b/rpcserver.go index ba787a28f..693e028ac 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -6758,7 +6758,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context, // First iterate through all the known nodes (connected or unconnected // within the graph), collating their current state into the RPC // response. - err := graph.ForEachNode(ctx, func(node *models.LightningNode) error { + err := graph.ForEachNode(ctx, func(node *models.Node) error { lnNode := marshalNode(node) resp.Nodes = append(resp.Nodes, lnNode) @@ -7114,7 +7114,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, }, nil } -func marshalNode(node *models.LightningNode) *lnrpc.LightningNode { +func marshalNode(node *models.Node) *lnrpc.LightningNode { nodeAddrs := make([]*lnrpc.NodeAddress, len(node.Addresses)) for i, addr := range node.Addresses { nodeAddr := &lnrpc.NodeAddress{ diff --git a/server.go b/server.go index 7238fa2b6..7b23662ad 100644 --- a/server.go +++ b/server.go @@ -3316,7 +3316,7 @@ func (s *server) createNewHiddenService(ctx context.Context) error { // Finally, we'll update the on-disk version of our announcement so it // will eventually propagate to nodes in the network. - selfNode := &models.LightningNode{ + selfNode := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: time.Unix(int64(newNodeAnn.Timestamp), 0), Addresses: newNodeAnn.Addresses, @@ -3505,7 +3505,7 @@ func (s *server) establishPersistentConnections(ctx context.Context) error { // each of the nodes. graphAddrs := make(map[string]*nodeAddresses) forEachSrcNodeChan := func(chanPoint wire.OutPoint, - havePolicy bool, channelPeer *models.LightningNode) error { + havePolicy bool, channelPeer *models.Node) error { // If the remote party has announced the channel to us, but we // haven't yet, then we won't have a policy. However, we don't @@ -5634,7 +5634,7 @@ func (s *server) setSelfNode(ctx context.Context, nodePub route.Vertex, // TODO(abdulkbk): potentially find a way to use the source node's // features in the self node. - selfNode := &models.LightningNode{ + selfNode := &models.Node{ HaveNodeAnnouncement: true, LastUpdate: nodeLastUpdate, Addresses: addrs,