Skip to content

Commit d08afa3

Browse files
authored
Merge pull request #10185 from ellemouton/renameLightningNode
multi: Rename LightningNode to Node
2 parents ea6cc81 + 6e98b33 commit d08afa3

27 files changed

+354
-359
lines changed

autopilot/graph.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ChannelGraphFromDatabase(db GraphSource) ChannelGraph {
4848
}
4949

5050
// type dbNode is a wrapper struct around a database transaction an
51-
// channeldb.LightningNode. The wrapper method implement the autopilot.Node
51+
// channeldb.Node. The wrapper method implement the autopilot.Node
5252
// interface.
5353
type dbNode struct {
5454
pub [33]byte
@@ -84,7 +84,7 @@ func (d *dbNode) Addrs() []net.Addr {
8484
func (d *databaseChannelGraph) ForEachNode(ctx context.Context,
8585
cb func(context.Context, Node) error, reset func()) error {
8686

87-
return d.db.ForEachNode(ctx, func(n *models.LightningNode) error {
87+
return d.db.ForEachNode(ctx, func(n *models.Node) error {
8888
// We'll skip over any node that doesn't have any advertised
8989
// addresses. As we won't be able to reach them to actually
9090
// open any channels.
@@ -161,7 +161,7 @@ func ChannelGraphFromCachedDatabase(db GraphSource) ChannelGraph {
161161
}
162162

163163
// dbNodeCached is a wrapper struct around a database transaction for a
164-
// channeldb.LightningNode. The wrapper methods implement the autopilot.Node
164+
// channeldb.Node. The wrapper methods implement the autopilot.Node
165165
// interface.
166166
type dbNodeCached struct {
167167
node route.Vertex

autopilot/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ type GraphSource interface {
230230
// graph, executing the passed callback with each node encountered. If
231231
// the callback returns an error, then the transaction is aborted and
232232
// the iteration stops early.
233-
ForEachNode(context.Context, func(*models.LightningNode) error,
233+
ForEachNode(context.Context, func(*models.Node) error,
234234
func()) error
235235

236236
// ForEachNodeCached is similar to ForEachNode, but it utilizes the

autopilot/prefattach_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
403403

404404
ctx := context.Background()
405405

406-
fetchNode := func(pub *btcec.PublicKey) (*models.LightningNode, error) {
406+
fetchNode := func(pub *btcec.PublicKey) (*models.Node, error) {
407407
if pub != nil {
408408
vertex, err := route.NewVertexFromBytes(
409409
pub.SerializeCompressed(),
@@ -412,12 +412,12 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
412412
return nil, err
413413
}
414414

415-
dbNode, err := d.db.FetchLightningNode(ctx, vertex)
415+
dbNode, err := d.db.FetchNode(ctx, vertex)
416416
switch {
417417
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
418418
fallthrough
419419
case errors.Is(err, graphdb.ErrGraphNotFound):
420-
graphNode := &models.LightningNode{
420+
graphNode := &models.Node{
421421
HaveNodeAnnouncement: true,
422422
Addresses: []net.Addr{&net.TCPAddr{
423423
IP: bytes.Repeat(
@@ -430,7 +430,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
430430
AuthSigBytes: testSig.Serialize(),
431431
}
432432
graphNode.AddPubKey(pub)
433-
err := d.db.AddLightningNode(
433+
err := d.db.AddNode(
434434
context.Background(), graphNode,
435435
)
436436
if err != nil {
@@ -447,7 +447,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
447447
if err != nil {
448448
return nil, err
449449
}
450-
dbNode := &models.LightningNode{
450+
dbNode := &models.Node{
451451
HaveNodeAnnouncement: true,
452452
Addresses: []net.Addr{
453453
&net.TCPAddr{
@@ -460,7 +460,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
460460
AuthSigBytes: testSig.Serialize(),
461461
}
462462
dbNode.AddPubKey(nodeKey)
463-
if err := d.db.AddLightningNode(
463+
if err := d.db.AddNode(
464464
context.Background(), dbNode,
465465
); err != nil {
466466
return nil, err
@@ -548,7 +548,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
548548
if err != nil {
549549
return nil, err
550550
}
551-
dbNode := &models.LightningNode{
551+
dbNode := &models.Node{
552552
HaveNodeAnnouncement: true,
553553
Addresses: []net.Addr{
554554
&net.TCPAddr{
@@ -561,7 +561,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
561561
AuthSigBytes: testSig.Serialize(),
562562
}
563563
dbNode.AddPubKey(nodeKey)
564-
err = d.db.AddLightningNode(context.Background(), dbNode)
564+
err = d.db.AddNode(context.Background(), dbNode)
565565
if err != nil {
566566
return nil, err
567567
}

channeldb/db_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,11 @@ func TestFetchPermTempPeer(t *testing.T) {
807807
)
808808
}
809809

810-
func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
810+
func createNode(priv *btcec.PrivateKey) *models.Node {
811811
updateTime := rand.Int63()
812812

813813
pub := priv.PubKey().SerializeCompressed()
814-
n := &models.LightningNode{
814+
n := &models.Node{
815815
HaveNodeAnnouncement: true,
816816
AuthSigBytes: testSig.Serialize(),
817817
LastUpdate: time.Unix(updateTime, 0),
@@ -825,9 +825,9 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
825825
return n
826826
}
827827

828-
func createTestVertex(t *testing.T) *models.LightningNode {
828+
func createTestVertex(t *testing.T) *models.Node {
829829
priv, err := btcec.NewPrivateKey()
830830
require.NoError(t, err)
831831

832-
return createLightningNode(priv)
832+
return createNode(priv)
833833
}

discovery/gossiper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context,
22352235
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
22362236
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
22372237

2238-
node, err := d.cfg.Graph.FetchLightningNode(ctx, pubKey)
2238+
node, err := d.cfg.Graph.FetchNode(ctx, pubKey)
22392239
if err != nil {
22402240
return nil, err
22412241
}

discovery/gossiper_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type mockGraphSource struct {
8383
bestHeight uint32
8484

8585
mu sync.Mutex
86-
nodes []models.LightningNode
86+
nodes []models.Node
8787
infos map[uint64]models.ChannelEdgeInfo
8888
edges map[uint64][]models.ChannelEdgePolicy
8989
zombies map[uint64][][33]byte
@@ -109,7 +109,7 @@ func newMockRouter(t *testing.T, height uint32) *mockGraphSource {
109109

110110
var _ graph.ChannelGraphSource = (*mockGraphSource)(nil)
111111

112-
func (r *mockGraphSource) AddNode(_ context.Context, node *models.LightningNode,
112+
func (r *mockGraphSource) AddNode(_ context.Context, node *models.Node,
113113
_ ...batch.SchedulerOption) error {
114114

115115
r.mu.Lock()
@@ -206,7 +206,7 @@ func (r *mockGraphSource) AddProof(chanID lnwire.ShortChannelID,
206206
}
207207

208208
func (r *mockGraphSource) ForEachNode(
209-
func(node *models.LightningNode) error) error {
209+
func(node *models.Node) error) error {
210210

211211
return nil
212212
}
@@ -295,8 +295,8 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) (
295295
return &chanInfo, edge1, edge2, nil
296296
}
297297

298-
func (r *mockGraphSource) FetchLightningNode(_ context.Context,
299-
nodePub route.Vertex) (*models.LightningNode, error) {
298+
func (r *mockGraphSource) FetchNode(_ context.Context,
299+
nodePub route.Vertex) (*models.Node, error) {
300300

301301
for _, node := range r.nodes {
302302
if bytes.Equal(nodePub[:], node.PubKeyBytes[:]) {

graph/builder.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
873873
// node announcements, we will ignore such nodes. If we do know about
874874
// this node, check that this update brings info newer than what we
875875
// already have.
876-
lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node)
876+
lastUpdate, exists, err := b.cfg.Graph.HasNode(ctx, node)
877877
if err != nil {
878878
return fmt.Errorf("unable to query for the "+
879879
"existence of node: %w", err)
@@ -975,7 +975,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
975975
// be ignored.
976976
//
977977
// NOTE: This method is part of the ChannelGraphSource interface.
978-
func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode,
978+
func (b *Builder) AddNode(ctx context.Context, node *models.Node,
979979
op ...batch.SchedulerOption) error {
980980

981981
err := b.addNode(ctx, node, op...)
@@ -988,11 +988,11 @@ func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode,
988988
return nil
989989
}
990990

991-
// addNode does some basic checks on the given LightningNode against what we
991+
// addNode does some basic checks on the given Node against what we
992992
// currently have persisted in the graph, and then adds it to the graph. If we
993993
// already know about the node, then we only update our DB if the new update
994994
// has a newer timestamp than the last one we received.
995-
func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
995+
func (b *Builder) addNode(ctx context.Context, node *models.Node,
996996
op ...batch.SchedulerOption) error {
997997

998998
// Before we add the node to the database, we'll check to see if the
@@ -1003,7 +1003,7 @@ func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
10031003
return err
10041004
}
10051005

1006-
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
1006+
if err := b.cfg.Graph.AddNode(ctx, node, op...); err != nil {
10071007
return fmt.Errorf("unable to add node %x to the "+
10081008
"graph: %w", node.PubKeyBytes, err)
10091009
}
@@ -1257,15 +1257,15 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) (
12571257
return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
12581258
}
12591259

1260-
// FetchLightningNode attempts to look up a target node by its identity public
1260+
// FetchNode attempts to look up a target node by its identity public
12611261
// key. graphdb.ErrGraphNodeNotFound is returned if the node doesn't exist
12621262
// within the graph.
12631263
//
12641264
// NOTE: This method is part of the ChannelGraphSource interface.
1265-
func (b *Builder) FetchLightningNode(ctx context.Context,
1266-
node route.Vertex) (*models.LightningNode, error) {
1265+
func (b *Builder) FetchNode(ctx context.Context,
1266+
node route.Vertex) (*models.Node, error) {
12671267

1268-
return b.cfg.Graph.FetchLightningNode(ctx, node)
1268+
return b.cfg.Graph.FetchNode(ctx, node)
12691269
}
12701270

12711271
// ForAllOutgoingChannels is used to iterate over all outgoing channels owned by

graph/builder_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
9797
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
9898

9999
pub := priv1.PubKey()
100-
node := &models.LightningNode{
100+
node := &models.Node{
101101
HaveNodeAnnouncement: true,
102102
LastUpdate: time.Unix(123, 0),
103103
Addresses: testAddrs,
@@ -1084,7 +1084,7 @@ func TestIsStaleNode(t *testing.T) {
10841084

10851085
// With the node stub in the database, we'll add the fully node
10861086
// announcement to the database.
1087-
n1 := &models.LightningNode{
1087+
n1 := &models.Node{
10881088
HaveNodeAnnouncement: true,
10891089
LastUpdate: updateTimeStamp,
10901090
Addresses: testAddrs,
@@ -1392,7 +1392,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
13921392
privKeyMap := make(map[string]*btcec.PrivateKey)
13931393
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
13941394
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
1395-
var source *models.LightningNode
1395+
var source *models.Node
13961396

13971397
// First we insert all the nodes within the graph as vertexes.
13981398
for _, node := range g.Nodes {
@@ -1401,7 +1401,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
14011401
return nil, err
14021402
}
14031403

1404-
dbNode := &models.LightningNode{
1404+
dbNode := &models.Node{
14051405
HaveNodeAnnouncement: true,
14061406
AuthSigBytes: testSig.Serialize(),
14071407
LastUpdate: testTime,
@@ -1475,7 +1475,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
14751475

14761476
// With the node fully parsed, add it as a vertex within the
14771477
// graph.
1478-
if err := graph.AddLightningNode(ctx, dbNode); err != nil {
1478+
if err := graph.AddNode(ctx, dbNode); err != nil {
14791479
return nil, err
14801480
}
14811481
}
@@ -1787,7 +1787,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
17871787
features = lnwire.EmptyFeatureVector()
17881788
}
17891789

1790-
dbNode := &models.LightningNode{
1790+
dbNode := &models.Node{
17911791
HaveNodeAnnouncement: true,
17921792
AuthSigBytes: testSig.Serialize(),
17931793
LastUpdate: testTime,
@@ -1806,7 +1806,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
18061806
err = graph.SetSourceNode(ctx, dbNode)
18071807
require.NoError(t, err)
18081808
} else {
1809-
err := graph.AddLightningNode(ctx, dbNode)
1809+
err := graph.AddNode(ctx, dbNode)
18101810
require.NoError(t, err)
18111811
}
18121812

graph/db/benchmark_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func TestPopulateDBs(t *testing.T) {
350350
countNodes := func(graph *ChannelGraph) int {
351351
numNodes := 0
352352
err := graph.ForEachNode(
353-
ctx, func(node *models.LightningNode) error {
353+
ctx, func(node *models.Node) error {
354354
numNodes++
355355

356356
return nil
@@ -580,12 +580,12 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
580580
}
581581

582582
var wgNodes sync.WaitGroup
583-
err := src.ForEachNode(ctx, func(node *models.LightningNode) error {
583+
err := src.ForEachNode(ctx, func(node *models.Node) error {
584584
wgNodes.Add(1)
585585
go func() {
586586
defer wgNodes.Done()
587587

588-
err := dest.AddLightningNode(ctx, node, batch.LazyAdd())
588+
err := dest.AddNode(ctx, node, batch.LazyAdd())
589589
require.NoError(t, err)
590590

591591
mu.Lock()
@@ -746,7 +746,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
746746
fn: func(b testing.TB, store V1Store) {
747747
err := store.ForEachNode(
748748
ctx,
749-
func(_ *models.LightningNode) error {
749+
func(_ *models.Node) error {
750750
// Increment the counter to
751751
// ensure the callback is doing
752752
// something.
@@ -932,10 +932,9 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
932932
numChannels = 0
933933
)
934934

935-
//nolint:ll
936935
err := store.ForEachNode(
937936
ctx,
938-
func(_ *models.LightningNode) error {
937+
func(_ *models.Node) error {
939938
numNodes++
940939

941940
return nil

graph/db/graph.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
266266
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
267267
}
268268

269-
// AddLightningNode adds a vertex/node to the graph database. If the node is not
269+
// AddNode adds a vertex/node to the graph database. If the node is not
270270
// in the database from before, this will add a new, unconnected one to the
271271
// graph. If it is present from before, this will update that node's
272272
// information. Note that this method is expected to only be called to update an
273273
// already present node from a node announcement, or to insert a node found in a
274274
// channel update.
275-
func (c *ChannelGraph) AddLightningNode(ctx context.Context,
276-
node *models.LightningNode, op ...batch.SchedulerOption) error {
275+
func (c *ChannelGraph) AddNode(ctx context.Context,
276+
node *models.Node, op ...batch.SchedulerOption) error {
277277

278-
err := c.V1Store.AddLightningNode(ctx, node, op...)
278+
err := c.V1Store.AddNode(ctx, node, op...)
279279
if err != nil {
280280
return err
281281
}
@@ -295,12 +295,12 @@ func (c *ChannelGraph) AddLightningNode(ctx context.Context,
295295
return nil
296296
}
297297

298-
// DeleteLightningNode starts a new database transaction to remove a vertex/node
298+
// DeleteNode starts a new database transaction to remove a vertex/node
299299
// from the database according to the node's public key.
300-
func (c *ChannelGraph) DeleteLightningNode(ctx context.Context,
300+
func (c *ChannelGraph) DeleteNode(ctx context.Context,
301301
nodePub route.Vertex) error {
302302

303-
err := c.V1Store.DeleteLightningNode(ctx, nodePub)
303+
err := c.V1Store.DeleteNode(ctx, nodePub)
304304
if err != nil {
305305
return err
306306
}

0 commit comments

Comments
 (0)