@@ -1288,13 +1288,10 @@ func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
12881288 TxIndex : math .MaxUint32 & 0x00ffffff ,
12891289 TxPosition : math .MaxUint16 ,
12901290 }
1291+ chanIDStart = channelIDToBytes (startSCID .ToUint64 ())
1292+ chanIDEnd = channelIDToBytes (endSCID .ToUint64 ())
12911293 )
12921294
1293- var chanIDStart [8 ]byte
1294- byteOrder .PutUint64 (chanIDStart [:], startSCID .ToUint64 ())
1295- var chanIDEnd [8 ]byte
1296- byteOrder .PutUint64 (chanIDEnd [:], endSCID .ToUint64 ())
1297-
12981295 // 1) get all channels where channelID is between start and end chan ID.
12991296 // 2) skip if not public (ie, no channel_proof)
13001297 // 3) collect that channel.
@@ -1638,9 +1635,8 @@ func updateChanEdgePolicy(ctx context.Context, tx SQLQueries,
16381635 var (
16391636 node1Pub , node2Pub route.Vertex
16401637 isNode1 bool
1641- chanIDB [ 8 ] byte
1638+ chanIDB = channelIDToBytes ( edge . ChannelID )
16421639 )
1643- byteOrder .PutUint64 (chanIDB [:], edge .ChannelID )
16441640
16451641 // Check that this edge policy refers to a channel that we already
16461642 // know of. We do this explicitly so that we can return the appropriate
@@ -2334,8 +2330,7 @@ func marshalExtraOpaqueData(data []byte) (map[uint64][]byte, error) {
23342330func insertChannel (ctx context.Context , db SQLQueries ,
23352331 edge * models.ChannelEdgeInfo ) error {
23362332
2337- var chanIDB [8 ]byte
2338- byteOrder .PutUint64 (chanIDB [:], edge .ChannelID )
2333+ chanIDB := channelIDToBytes (edge .ChannelID )
23392334
23402335 // Make sure that the channel doesn't already exist. We do this
23412336 // explicitly instead of relying on catching a unique constraint error
@@ -2920,3 +2915,12 @@ func extractChannelPolicies(row any) (*sqlc.ChannelPolicy, *sqlc.ChannelPolicy,
29202915 "extractChannelPolicies: %T" , r )
29212916 }
29222917}
2918+
2919+ // channelIDToBytes converts a channel ID (SCID) to a byte array
2920+ // representation.
2921+ func channelIDToBytes (channelID uint64 ) [8 ]byte {
2922+ var chanIDB [8 ]byte
2923+ byteOrder .PutUint64 (chanIDB [:], channelID )
2924+
2925+ return chanIDB
2926+ }
0 commit comments