graph/db: refactor buildNode to not take a pointer
What changed, and why it matters
This commit is a small internal code cleanup in LND's graph database code. It changes a helper function so it receives a copy of a data record instead of a pointer to that record. There is no user-facing change, no bug fix, and no security relevance visible in the diff or commit message.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors buildNode and buildNodeWithBatchData in graph/db/sql_store.go to accept sqlc.GraphNode by value rather than by pointer. All call sites are updated to pass dbNode directly instead of &dbNode. The commit message explicitly frames this as a refactor that will be useful later. No logic, query, authorization, cryptography, or input handling changes are present.
Changed components
graph/db/sql_store.gograph/db/sql_migration.goInspect captured patch +8 / −8
diff --git a/graph/db/sql_migration.go b/graph/db/sql_migration.go
index e1ff256..8a52976 100644
--- a/graph/db/sql_migration.go
+++ b/graph/db/sql_migration.go
@@ -192,7 +192,7 @@ func migrateNodes(ctx context.Context, kvBackend kvdb.Backend,
pub, id, dbNode.ID)
}
- migratedNode, err := buildNode(ctx, sqlDB, &dbNode)
+ migratedNode, err := buildNode(ctx, sqlDB, dbNode)
if err != nil {
return fmt.Errorf("could not build migrated node "+
"from dbNode(db id: %d, node pub: %x): %w",
diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go
index c991c3b..95b4ad2 100644
--- a/graph/db/sql_store.go
+++ b/graph/db/sql_store.go
@@ -3231,7 +3231,7 @@ func getNodeByPubKey(ctx context.Context, db SQLQueries,
return 0, nil, fmt.Errorf("unable to fetch node: %w", err)
}
- node, err := buildNode(ctx, db, &dbNode)
+ node, err := buildNode(ctx, db, dbNode)
if err != nil {
return 0, nil, fmt.Errorf("unable to build node: %w", err)
}
@@ -3256,7 +3256,7 @@ func buildCacheableChannelInfo(scid []byte, capacity int64, node1Pub,
// 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, db SQLQueries,
- dbNode *sqlc.GraphNode) (*models.LightningNode, error) {
+ dbNode sqlc.GraphNode) (*models.LightningNode, error) {
// NOTE: buildNode is only used to load the data for a single node, and
// so no paged queries will be performed. This means that it's ok to
@@ -3276,7 +3276,7 @@ func buildNode(ctx context.Context, db SQLQueries,
// 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,
+func buildNodeWithBatchData(dbNode sqlc.GraphNode,
batchData *batchNodeData) (*models.LightningNode, error) {
if dbNode.Version != int16(ProtocolV1) {
@@ -3364,7 +3364,7 @@ func forEachNodeInBatch(ctx context.Context, cfg *sqldb.QueryConfig,
}
for _, dbNode := range nodes {
- node, err := buildNodeWithBatchData(&dbNode, batchData)
+ node, err := buildNodeWithBatchData(dbNode, batchData)
if err != nil {
return fmt.Errorf("unable to build node(id=%d): %w",
dbNode.ID, err)
@@ -4235,12 +4235,12 @@ func buildNodes(ctx context.Context, db SQLQueries, dbNode1,
dbNode2 sqlc.GraphNode) (*models.LightningNode, *models.LightningNode,
error) {
- node1, err := buildNode(ctx, db, &dbNode1)
+ node1, err := buildNode(ctx, db, dbNode1)
if err != nil {
return nil, nil, err
}
- node2, err := buildNode(ctx, db, &dbNode2)
+ node2, err := buildNode(ctx, db, dbNode2)
if err != nil {
return nil, nil, err
}
@@ -5090,7 +5090,7 @@ func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig,
processItem := func(ctx context.Context, dbNode sqlc.GraphNode,
batchData *batchNodeData) error {
- node, err := buildNodeWithBatchData(&dbNode, batchData)
+ node, err := buildNodeWithBatchData(dbNode, batchData)
if err != nil {
return fmt.Errorf("unable to build "+
"node(id=%d): %w", dbNode.ID, err)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.