From b13b0bb92211d73de7dbaeff6163e654c4eff869 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 19 Nov 2025 08:18:21 +0200 Subject: [PATCH] graph/db: expose version in maybeCreateShellNode Add a version parameter to maybeCreateShellNode to allow callers to specify which gossip protocol version should be used when creating shell nodes. Currently all callers pass GossipVersion1, but this change sets up the foundation for v2 support. Shell nodes are lightweight node entries containing only a protocol version and public key, created before full node information is available. --- graph/db/sql_store.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 2c794fa95..a1592eacf 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 {