graph/db: expose version in maybeCreateShellNode
What changed, and why it matters
This is a small, straightforward code cleanup change. It adds a 'version' parameter to an internal helper function so that future code can choose between gossip protocol versions. Right now every caller still hardcodes version 1, so behavior is unchanged. There is no security issue visible in this commit.
No security action required. Review as normal code-quality/refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors maybeCreateShellNode in graph/db/sql_store.go to accept a lnwire.GossipVersion argument instead of always using lnwire.GossipVersion1. The only caller, insertChannel, now passes a local v := lnwire.GossipVersion1 and reuses that variable for both shell-node creation and the subsequent CreateChannelParams.Version field. The diff is purely structural: no caller passes a different version, no validation logic is added or removed, and the database query parameters remain identical in practice.
Changed components
graph/db/sql_store.gomaybeCreateShellNodeinsertChannelInspect captured patch +12 / −6
diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go
index 2c794fa..a1592ea 100644
--- a/graph/db/sql_store.go
+++ b/graph/db/sql_store.go
@@ -4239,14 +4239,20 @@ func marshalExtraOpaqueData(data []byte) (map[uint64][]byte, error) {
func insertChannel(ctx context.Context, db SQLQueries,
edge *models.ChannelEdgeInfo) error {
+ v := lnwire.GossipVersion1
+
// Make sure that at least a "shell" entry for each node is present in
// the nodes table.
- node1DBID, err := maybeCreateShellNode(ctx, db, edge.NodeKey1Bytes)
+ node1DBID, err := maybeCreateShellNode(
+ ctx, db, v, edge.NodeKey1Bytes,
+ )
if err != nil {
return fmt.Errorf("unable to create shell node: %w", err)
}
- node2DBID, err := maybeCreateShellNode(ctx, db, edge.NodeKey2Bytes)
+ node2DBID, err := maybeCreateShellNode(
+ ctx, db, v, edge.NodeKey2Bytes,
+ )
if err != nil {
return fmt.Errorf("unable to create shell node: %w", err)
}
@@ -4257,7 +4263,7 @@ func insertChannel(ctx context.Context, db SQLQueries,
}
createParams := sqlc.CreateChannelParams{
- Version: int16(lnwire.GossipVersion1),
+ Version: int16(v),
Scid: channelIDToBytes(edge.ChannelID),
NodeID1: node1DBID,
NodeID2: node2DBID,
@@ -4326,12 +4332,12 @@ func insertChannel(ctx context.Context, db SQLQueries,
// created. The ID of the node is returned. A shell node only has a protocol
// version and public key persisted.
func maybeCreateShellNode(ctx context.Context, db SQLQueries,
- pubKey route.Vertex) (int64, error) {
+ v lnwire.GossipVersion, pubKey route.Vertex) (int64, error) {
dbNode, err := db.GetNodeByPubKey(
ctx, sqlc.GetNodeByPubKeyParams{
PubKey: pubKey[:],
- Version: int16(lnwire.GossipVersion1),
+ Version: int16(v),
},
)
// The node exists. Return the ID.
@@ -4344,7 +4350,7 @@ func maybeCreateShellNode(ctx context.Context, db SQLQueries,
// Otherwise, the node does not exist, so we create a shell entry for
// it.
id, err := db.UpsertNode(ctx, sqlc.UpsertNodeParams{
- Version: int16(lnwire.GossipVersion1),
+ Version: int16(v),
PubKey: pubKey[:],
})
if err != nil {
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.