From b57714b00c7f6b46d1dec299c60ae4aa5e4008a7 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 15 Sep 2025 12:31:40 +0200 Subject: [PATCH] graph/db: use lnwire.GossipVersion instead of ProtocolVersion --- graph/db/sql_migration.go | 16 ++--- graph/db/sql_store.go | 128 ++++++++++++++++++-------------------- 2 files changed, 70 insertions(+), 74 deletions(-) diff --git a/graph/db/sql_migration.go b/graph/db/sql_migration.go index 7cc4c414e..e73771800 100644 --- a/graph/db/sql_migration.go +++ b/graph/db/sql_migration.go @@ -423,7 +423,7 @@ func migrateSourceNode(ctx context.Context, kvdb kvdb.Backend, id, err := sqlDB.GetNodeIDByPubKey( ctx, sqlc.GetNodeIDByPubKeyParams{ PubKey: pub[:], - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err != nil { @@ -441,7 +441,9 @@ func migrateSourceNode(ctx context.Context, kvdb kvdb.Backend, // from the SQL database and checking that the expected DB ID and // pub key are returned. We don't need to do a whole node comparison // here, as this was already done in the previous migration step. - srcNodes, err := sqlDB.GetSourceNodesByVersion(ctx, int16(ProtocolV1)) + srcNodes, err := sqlDB.GetSourceNodesByVersion( + ctx, int16(lnwire.GossipVersion1), + ) if err != nil { return fmt.Errorf("could not get source nodes from SQL "+ "store: %w", err) @@ -1251,7 +1253,7 @@ func migrateZombieIndex(ctx context.Context, cfg *sqldb.QueryConfig, // Batch fetch all zombie channels from the database. rows, err := sqlDB.GetZombieChannelsSCIDs( ctx, sqlc.GetZombieChannelsSCIDsParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scids: scids, }, ) @@ -1327,7 +1329,7 @@ func migrateZombieIndex(ctx context.Context, cfg *sqldb.QueryConfig, err = sqlDB.UpsertZombieChannel( ctx, sqlc.UpsertZombieChannelParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scid: chanIDB, NodeKey1: pubKey1[:], NodeKey2: pubKey2[:], @@ -1443,7 +1445,7 @@ func insertNodeSQLMig(ctx context.Context, db SQLQueries, node *models.Node) (int64, error) { params := sqlc.InsertNodeMigParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: node.PubKeyBytes[:], } @@ -1564,7 +1566,7 @@ func insertChannelMig(ctx context.Context, db SQLQueries, } createParams := sqlc.InsertChannelMigParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scid: channelIDToBytes(edge.ChannelID), NodeID1: node1DBID, NodeID2: node2DBID, @@ -1655,7 +1657,7 @@ func insertChanEdgePolicyMig(ctx context.Context, tx SQLQueries, }) id, err := tx.InsertEdgePolicyMig(ctx, sqlc.InsertEdgePolicyMigParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: dbChan.channelID, NodeID: nodeID, Timelock: int32(edge.TimeLockDelta), diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index f67894e4c..c9283df88 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -32,20 +32,6 @@ import ( "github.com/lightningnetwork/lnd/tor" ) -// ProtocolVersion is an enum that defines the gossip protocol version of a -// message. -type ProtocolVersion uint8 - -const ( - // ProtocolV1 is the gossip protocol version defined in BOLT #7. - ProtocolV1 ProtocolVersion = 1 -) - -// String returns a string representation of the protocol version. -func (v ProtocolVersion) String() string { - return fmt.Sprintf("V%d", v) -} - // SQLQueries is a subset of the sqlc.Querier interface that can be used to // execute queries against the SQL graph tables. // @@ -191,7 +177,7 @@ type SQLStore struct { chanScheduler batch.Scheduler[SQLQueries] nodeScheduler batch.Scheduler[SQLQueries] - srcNodes map[ProtocolVersion]*srcNodeInfo + srcNodes map[lnwire.GossipVersion]*srcNodeInfo srcNodeMu sync.Mutex } @@ -229,7 +215,7 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries, db: db, rejectCache: newRejectCache(opts.RejectCacheSize), chanCache: newChannelCache(opts.ChannelCacheSize), - srcNodes: make(map[ProtocolVersion]*srcNodeInfo), + srcNodes: make(map[lnwire.GossipVersion]*srcNodeInfo), } s.chanScheduler = batch.NewTimeScheduler( @@ -312,7 +298,7 @@ func (s *SQLStore) HasNode(ctx context.Context, err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: pubKey[:], }, ) @@ -355,7 +341,7 @@ func (s *SQLStore) AddrsForNode(ctx context.Context, // does. dbID, err := db.GetNodeIDByPubKey( ctx, sqlc.GetNodeIDByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: nodePub.SerializeCompressed(), }, ) @@ -391,7 +377,7 @@ func (s *SQLStore) DeleteNode(ctx context.Context, err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error { res, err := db.DeleteNodeByPubKey( ctx, sqlc.DeleteNodeByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: pubKey[:], }, ) @@ -470,7 +456,7 @@ func (s *SQLStore) LookupAlias(ctx context.Context, err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: pub.SerializeCompressed(), }, ) @@ -506,7 +492,9 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node, var node *models.Node err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { - _, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1) + _, nodePub, err := s.getSourceNode( + ctx, db, lnwire.GossipVersion1, + ) if err != nil { return fmt.Errorf("unable to fetch V1 source node: %w", err) @@ -540,7 +528,9 @@ func (s *SQLStore) SetSourceNode(ctx context.Context, // Make sure that if a source node for this version is already // set, then the ID is the same as the one we are about to set. - dbSourceNodeID, _, err := s.getSourceNode(ctx, db, ProtocolV1) + dbSourceNodeID, _, err := s.getSourceNode( + ctx, db, lnwire.GossipVersion1, + ) if err != nil && !errors.Is(err, ErrSourceNodeNotSet) { return fmt.Errorf("unable to fetch source node: %w", err) @@ -693,7 +683,7 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context, _, err := tx.GetChannelBySCID( ctx, sqlc.GetChannelBySCIDParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err == nil { @@ -731,7 +721,7 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context, func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) { var highestChanID uint64 err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { - chanID, err := db.HighestSCID(ctx, int16(ProtocolV1)) + chanID, err := db.HighestSCID(ctx, int16(lnwire.GossipVersion1)) if errors.Is(err, sql.ErrNoRows) { return nil } else if err != nil { @@ -862,7 +852,9 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context, 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) + nodeID, nodePub, err := s.getSourceNode( + ctx, db, lnwire.GossipVersion1, + ) if err != nil { return fmt.Errorf("unable to fetch source node: %w", err) @@ -920,7 +912,7 @@ func (s *SQLStore) ForEachNode(ctx context.Context, return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { return forEachNodePaginated( ctx, s.cfg.QueryCfg, db, - ProtocolV1, func(_ context.Context, _ int64, + lnwire.GossipVersion1, func(_ context.Context, _ int64, node *models.Node) error { return cb(node) @@ -989,7 +981,7 @@ func (s *SQLStore) ForEachNodeChannel(ctx context.Context, nodePub route.Vertex, return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: nodePub[:], }, ) @@ -1130,7 +1122,7 @@ func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time, func(db SQLQueries) error { //nolint:ll params := sqlc.GetChannelsByPolicyLastUpdateRangeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), StartTime: sqldb.SQLInt64( startTime.Unix(), ), @@ -1278,7 +1270,7 @@ func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool, return db.ListNodeIDsAndPubKeys( ctx, sqlc.ListNodeIDsAndPubKeysParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ID: lastID, Limit: limit, }, @@ -1316,7 +1308,7 @@ func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool, // page. allChannels, err := db.ListChannelsForNodeIDs( ctx, sqlc.ListChannelsForNodeIDsParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Node1Ids: nodeIDs, Node2Ids: nodeIDs, }, @@ -1531,7 +1523,7 @@ func (s *SQLStore) ForEachChannelCacheable(cb func(*models.CachedEdgeInfo, return db.ListChannelsWithPoliciesForCachePaginated( ctx, sqlc.ListChannelsWithPoliciesForCachePaginatedParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ID: lastID, Limit: limit, }, @@ -1629,7 +1621,7 @@ func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32, //nolint:ll node1Policy, err := db.GetChannelPolicyByChannelAndNode( ctx, sqlc.GetChannelPolicyByChannelAndNodeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: dbChan.ID, NodeID: dbChan.NodeID1, }, @@ -1646,7 +1638,7 @@ func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32, //nolint:ll node2Policy, err := db.GetChannelPolicyByChannelAndNode( ctx, sqlc.GetChannelPolicyByChannelAndNodeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: dbChan.ID, NodeID: dbChan.NodeID2, }, @@ -1707,7 +1699,7 @@ func (s *SQLStore) MarkEdgeZombie(chanID uint64, err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error { return db.UpsertZombieChannel( ctx, sqlc.UpsertZombieChannelParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scid: chanIDB, NodeKey1: pubKey1[:], NodeKey2: pubKey2[:], @@ -1741,7 +1733,7 @@ func (s *SQLStore) MarkEdgeLive(chanID uint64) error { res, err := db.DeleteZombieChannel( ctx, sqlc.DeleteZombieChannelParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err != nil { @@ -1793,7 +1785,7 @@ func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte, zombie, err := db.GetZombieChannel( ctx, sqlc.GetZombieChannelParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -1828,7 +1820,9 @@ func (s *SQLStore) NumZombies() (uint64, error) { numZombies uint64 ) err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { - count, err := db.CountZombieChannels(ctx, int16(ProtocolV1)) + count, err := db.CountZombieChannels( + ctx, int16(lnwire.GossipVersion1), + ) if err != nil { return fmt.Errorf("unable to count zombie channels: %w", err) @@ -1974,7 +1968,7 @@ func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) ( row, err := db.GetChannelBySCIDWithPolicies( ctx, sqlc.GetChannelBySCIDWithPoliciesParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -1983,7 +1977,7 @@ func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) ( zombie, err := db.GetZombieChannel( ctx, sqlc.GetZombieChannelParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -2070,7 +2064,7 @@ func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) ( row, err := db.GetChannelByOutpointWithPolicies( ctx, sqlc.GetChannelByOutpointWithPoliciesParams{ Outpoint: op.String(), - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -2171,7 +2165,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool, channel, err := db.GetChannelBySCID( ctx, sqlc.GetChannelBySCIDParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -2179,7 +2173,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool, isZombie, err = db.IsZombieChannel( ctx, sqlc.IsZombieChannelParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err != nil { @@ -2196,7 +2190,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool, policy1, err := db.GetChannelPolicyByChannelAndNode( ctx, sqlc.GetChannelPolicyByChannelAndNodeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: channel.ID, NodeID: channel.NodeID1, }, @@ -2210,7 +2204,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool, policy2, err := db.GetChannelPolicyByChannelAndNode( ctx, sqlc.GetChannelPolicyByChannelAndNodeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: channel.ID, NodeID: channel.NodeID2, }, @@ -2252,7 +2246,7 @@ func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) { chanID, err := db.GetSCIDByOutpoint( ctx, sqlc.GetSCIDByOutpointParams{ Outpoint: chanPoint.String(), - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -2377,7 +2371,7 @@ func (s *SQLStore) forEachChanWithPoliciesInSCIDList(ctx context.Context, return db.GetChannelsBySCIDWithPolicies( ctx, sqlc.GetChannelsBySCIDWithPoliciesParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scids: scids, }, ) @@ -2447,7 +2441,7 @@ func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64, isZombie, err := db.IsZombieChannel( ctx, sqlc.IsZombieChannelParams{ Scid: channelIDToBytes(channelID), - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err != nil { @@ -2494,7 +2488,7 @@ func (s *SQLStore) forEachChanInSCIDList(ctx context.Context, db SQLQueries, return db.GetChannelsBySCIDs( ctx, sqlc.GetChannelsBySCIDsParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scids: scids, }, ) @@ -2740,7 +2734,7 @@ func (s *SQLStore) ChannelView() ([]EdgePoint, error) { return db.ListChannelsPaginated( ctx, sqlc.ListChannelsPaginatedParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ID: lastID, Limit: limit, }, @@ -3080,7 +3074,7 @@ func forEachNodeDirectedChannel(ctx context.Context, db SQLQueries, dbID, err := db.GetNodeIDByPubKey( ctx, sqlc.GetNodeIDByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: nodePub[:], }, ) @@ -3092,7 +3086,7 @@ func forEachNodeDirectedChannel(ctx context.Context, db SQLQueries, rows, err := db.ListChannelsByNodeID( ctx, sqlc.ListChannelsByNodeIDParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), NodeID1: dbID, }, ) @@ -3208,7 +3202,7 @@ func forEachNodeCacheable(ctx context.Context, cfg *sqldb.QueryConfig, return db.ListNodeIDsAndPubKeys( ctx, sqlc.ListNodeIDsAndPubKeysParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ID: lastID, Limit: limit, }, @@ -3247,7 +3241,7 @@ func forEachNodeChannel(ctx context.Context, db SQLQueries, // Get all the V1 channels for this node. rows, err := db.ListChannelsByNodeID( ctx, sqlc.ListChannelsByNodeIDParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), NodeID1: id, }, ) @@ -3349,7 +3343,7 @@ func updateChanEdgePolicy(ctx context.Context, tx SQLQueries, dbChan, err := tx.GetChannelAndNodesBySCID( ctx, sqlc.GetChannelAndNodesBySCIDParams{ Scid: chanIDB, - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if errors.Is(err, sql.ErrNoRows) { @@ -3379,7 +3373,7 @@ func updateChanEdgePolicy(ctx context.Context, tx SQLQueries, }) id, err := tx.UpsertEdgePolicy(ctx, sqlc.UpsertEdgePolicyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ChannelID: dbChan.ID, NodeID: nodeID, Timelock: int32(edge.TimeLockDelta), @@ -3430,7 +3424,7 @@ func getNodeByPubKey(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: pubKey[:], }, ) @@ -3483,7 +3477,7 @@ func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries, func buildNodeWithBatchData(dbNode sqlc.GraphNode, batchData *batchNodeData) (*models.Node, error) { - if dbNode.Version != int16(ProtocolV1) { + if dbNode.Version != int16(lnwire.GossipVersion1) { return nil, fmt.Errorf("unsupported node version: %d", dbNode.Version) } @@ -3610,7 +3604,7 @@ func upsertNode(ctx context.Context, db SQLQueries, node *models.Node) (int64, error) { params := sqlc.UpsertNodeParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: node.PubKeyBytes[:], } @@ -3729,7 +3723,7 @@ func fetchNodeFeatures(ctx context.Context, queries SQLQueries, rows, err := queries.GetNodeFeaturesByPubKey( ctx, sqlc.GetNodeFeaturesByPubKeyParams{ PubKey: nodePub[:], - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) if err != nil { @@ -3964,7 +3958,7 @@ type srcNodeInfo struct { // sourceNode returns the DB node ID and pub key of the source node for the // specified protocol version. func (s *SQLStore) getSourceNode(ctx context.Context, db SQLQueries, - version ProtocolVersion) (int64, route.Vertex, error) { + version lnwire.GossipVersion) (int64, route.Vertex, error) { s.srcNodeMu.Lock() defer s.srcNodeMu.Unlock() @@ -4051,7 +4045,7 @@ func insertChannel(ctx context.Context, db SQLQueries, } createParams := sqlc.CreateChannelParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scid: channelIDToBytes(edge.ChannelID), NodeID1: node1DBID, NodeID2: node2DBID, @@ -4125,7 +4119,7 @@ func maybeCreateShellNode(ctx context.Context, db SQLQueries, dbNode, err := db.GetNodeByPubKey( ctx, sqlc.GetNodeByPubKeyParams{ PubKey: pubKey[:], - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), }, ) // The node exists. Return the ID. @@ -4138,7 +4132,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(ProtocolV1), + Version: int16(lnwire.GossipVersion1), PubKey: pubKey[:], }) if err != nil { @@ -4206,7 +4200,7 @@ func buildEdgeInfoWithBatchData(chain chainhash.Hash, dbChan sqlc.GraphChannel, node1, node2 route.Vertex, batchData *batchChannelData) (*models.ChannelEdgeInfo, error) { - if dbChan.Version != int16(ProtocolV1) { + if dbChan.Version != int16(lnwire.GossipVersion1) { return nil, fmt.Errorf("unsupported channel version: %d", dbChan.Version) } @@ -5287,7 +5281,7 @@ func batchLoadChannelPolicyExtrasHelper(ctx context.Context, // graph. It uses the provided SQLQueries interface to fetch nodes in batches // and applies the provided processNode function to each node. func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig, - db SQLQueries, protocol ProtocolVersion, + db SQLQueries, protocol lnwire.GossipVersion, processNode func(context.Context, int64, *models.Node) error) error { @@ -5353,7 +5347,7 @@ func forEachChannelWithPolicies(ctx context.Context, db SQLQueries, return db.ListChannelsWithPoliciesPaginated( ctx, sqlc.ListChannelsWithPoliciesPaginatedParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), ID: lastID, Limit: limit, }, @@ -5726,7 +5720,7 @@ func handleZombieMarking(ctx context.Context, db SQLQueries, return db.UpsertZombieChannel( ctx, sqlc.UpsertZombieChannelParams{ - Version: int16(ProtocolV1), + Version: int16(lnwire.GossipVersion1), Scid: channelIDToBytes(scid), NodeKey1: nodeKey1[:], NodeKey2: nodeKey2[:],