• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16313565012

16 Jul 2025 07:46AM UTC coverage: 67.205% (-0.1%) from 67.321%
16313565012

Pull #10081

github

web-flow
Merge bf32adb8a into 9059a4e7b
Pull Request #10081: graph/db: use `/*SLICE:<field_name>*/` to optimise various graph queries

0 of 379 new or added lines in 4 files covered. (0.0%)

99 existing lines in 24 files now uncovered.

135374 of 201433 relevant lines covered (67.21%)

21718.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sqldb/sqlc/graph.sql.go
1
// Code generated by sqlc. DO NOT EDIT.
2
// versions:
3
//   sqlc v1.29.0
4
// source: graph.sql
5

6
package sqlc
7

8
import (
9
        "context"
10
        "database/sql"
11
        "strings"
12
)
13

14
const addSourceNode = `-- name: AddSourceNode :exec
15
/* ─────────────────────────────────────────────
16
   graph_source_nodes table queries
17
   ─────────────────────────────────────────────
18
*/
19

20
INSERT INTO graph_source_nodes (node_id)
21
VALUES ($1)
22
ON CONFLICT (node_id) DO NOTHING
23
`
24

25
func (q *Queries) AddSourceNode(ctx context.Context, nodeID int64) error {
×
26
        _, err := q.db.ExecContext(ctx, addSourceNode, nodeID)
×
27
        return err
×
28
}
×
29

30
const addV1ChannelProof = `-- name: AddV1ChannelProof :execresult
31
UPDATE graph_channels
32
SET node_1_signature = $2,
33
    node_2_signature = $3,
34
    bitcoin_1_signature = $4,
35
    bitcoin_2_signature = $5
36
WHERE scid = $1
37
  AND version = 1
38
`
39

40
type AddV1ChannelProofParams struct {
41
        Scid              []byte
42
        Node1Signature    []byte
43
        Node2Signature    []byte
44
        Bitcoin1Signature []byte
45
        Bitcoin2Signature []byte
46
}
47

48
func (q *Queries) AddV1ChannelProof(ctx context.Context, arg AddV1ChannelProofParams) (sql.Result, error) {
×
49
        return q.db.ExecContext(ctx, addV1ChannelProof,
×
50
                arg.Scid,
×
51
                arg.Node1Signature,
×
52
                arg.Node2Signature,
×
53
                arg.Bitcoin1Signature,
×
54
                arg.Bitcoin2Signature,
×
55
        )
×
56
}
×
57

58
const countZombieChannels = `-- name: CountZombieChannels :one
59
SELECT COUNT(*)
60
FROM graph_zombie_channels
61
WHERE version = $1
62
`
63

64
func (q *Queries) CountZombieChannels(ctx context.Context, version int16) (int64, error) {
×
65
        row := q.db.QueryRowContext(ctx, countZombieChannels, version)
×
66
        var count int64
×
67
        err := row.Scan(&count)
×
68
        return count, err
×
69
}
×
70

71
const createChannel = `-- name: CreateChannel :one
72
/* ─────────────────────────────────────────────
73
   graph_channels table queries
74
   ─────────────────────────────────────────────
75
*/
76

77
INSERT INTO graph_channels (
78
    version, scid, node_id_1, node_id_2,
79
    outpoint, capacity, bitcoin_key_1, bitcoin_key_2,
80
    node_1_signature, node_2_signature, bitcoin_1_signature,
81
    bitcoin_2_signature
82
) VALUES (
83
    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
84
)
85
RETURNING id
86
`
87

88
type CreateChannelParams struct {
89
        Version           int16
90
        Scid              []byte
91
        NodeID1           int64
92
        NodeID2           int64
93
        Outpoint          string
94
        Capacity          sql.NullInt64
95
        BitcoinKey1       []byte
96
        BitcoinKey2       []byte
97
        Node1Signature    []byte
98
        Node2Signature    []byte
99
        Bitcoin1Signature []byte
100
        Bitcoin2Signature []byte
101
}
102

103
func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (int64, error) {
×
104
        row := q.db.QueryRowContext(ctx, createChannel,
×
105
                arg.Version,
×
106
                arg.Scid,
×
107
                arg.NodeID1,
×
108
                arg.NodeID2,
×
109
                arg.Outpoint,
×
110
                arg.Capacity,
×
111
                arg.BitcoinKey1,
×
112
                arg.BitcoinKey2,
×
113
                arg.Node1Signature,
×
114
                arg.Node2Signature,
×
115
                arg.Bitcoin1Signature,
×
116
                arg.Bitcoin2Signature,
×
117
        )
×
118
        var id int64
×
119
        err := row.Scan(&id)
×
120
        return id, err
×
121
}
×
122

123
const createChannelExtraType = `-- name: CreateChannelExtraType :exec
124
/* ─────────────────────────────────────────────
125
   graph_channel_extra_types table queries
126
   ─────────────────────────────────────────────
127
*/
128

129
INSERT INTO graph_channel_extra_types (
130
    channel_id, type, value
131
)
132
VALUES ($1, $2, $3)
133
`
134

135
type CreateChannelExtraTypeParams struct {
136
        ChannelID int64
137
        Type      int64
138
        Value     []byte
139
}
140

141
func (q *Queries) CreateChannelExtraType(ctx context.Context, arg CreateChannelExtraTypeParams) error {
×
142
        _, err := q.db.ExecContext(ctx, createChannelExtraType, arg.ChannelID, arg.Type, arg.Value)
×
143
        return err
×
144
}
×
145

146
const deleteChannel = `-- name: DeleteChannel :exec
147
DELETE FROM graph_channels WHERE id = $1
148
`
149

150
func (q *Queries) DeleteChannel(ctx context.Context, id int64) error {
×
151
        _, err := q.db.ExecContext(ctx, deleteChannel, id)
×
152
        return err
×
153
}
×
154

155
const deleteChannelPolicyExtraTypes = `-- name: DeleteChannelPolicyExtraTypes :exec
156
DELETE FROM graph_channel_policy_extra_types
157
WHERE channel_policy_id = $1
158
`
159

160
func (q *Queries) DeleteChannelPolicyExtraTypes(ctx context.Context, channelPolicyID int64) error {
×
161
        _, err := q.db.ExecContext(ctx, deleteChannelPolicyExtraTypes, channelPolicyID)
×
162
        return err
×
163
}
×
164

165
const deleteExtraNodeType = `-- name: DeleteExtraNodeType :exec
166
DELETE FROM graph_node_extra_types
167
WHERE node_id = $1
168
  AND type = $2
169
`
170

171
type DeleteExtraNodeTypeParams struct {
172
        NodeID int64
173
        Type   int64
174
}
175

176
func (q *Queries) DeleteExtraNodeType(ctx context.Context, arg DeleteExtraNodeTypeParams) error {
×
177
        _, err := q.db.ExecContext(ctx, deleteExtraNodeType, arg.NodeID, arg.Type)
×
178
        return err
×
179
}
×
180

181
const deleteNode = `-- name: DeleteNode :exec
182
DELETE FROM graph_nodes
183
WHERE id = $1
184
`
185

186
func (q *Queries) DeleteNode(ctx context.Context, id int64) error {
×
187
        _, err := q.db.ExecContext(ctx, deleteNode, id)
×
188
        return err
×
189
}
×
190

191
const deleteNodeAddresses = `-- name: DeleteNodeAddresses :exec
192
DELETE FROM graph_node_addresses
193
WHERE node_id = $1
194
`
195

196
func (q *Queries) DeleteNodeAddresses(ctx context.Context, nodeID int64) error {
×
197
        _, err := q.db.ExecContext(ctx, deleteNodeAddresses, nodeID)
×
198
        return err
×
199
}
×
200

201
const deleteNodeByPubKey = `-- name: DeleteNodeByPubKey :execresult
202
DELETE FROM graph_nodes
203
WHERE pub_key = $1
204
  AND version = $2
205
`
206

207
type DeleteNodeByPubKeyParams struct {
208
        PubKey  []byte
209
        Version int16
210
}
211

212
func (q *Queries) DeleteNodeByPubKey(ctx context.Context, arg DeleteNodeByPubKeyParams) (sql.Result, error) {
×
213
        return q.db.ExecContext(ctx, deleteNodeByPubKey, arg.PubKey, arg.Version)
×
214
}
×
215

216
const deleteNodeFeature = `-- name: DeleteNodeFeature :exec
217
DELETE FROM graph_node_features
218
WHERE node_id = $1
219
  AND feature_bit = $2
220
`
221

222
type DeleteNodeFeatureParams struct {
223
        NodeID     int64
224
        FeatureBit int32
225
}
226

227
func (q *Queries) DeleteNodeFeature(ctx context.Context, arg DeleteNodeFeatureParams) error {
×
228
        _, err := q.db.ExecContext(ctx, deleteNodeFeature, arg.NodeID, arg.FeatureBit)
×
229
        return err
×
230
}
×
231

232
const deletePruneLogEntriesInRange = `-- name: DeletePruneLogEntriesInRange :exec
233
DELETE FROM graph_prune_log
234
WHERE block_height >= $1
235
  AND block_height <= $2
236
`
237

238
type DeletePruneLogEntriesInRangeParams struct {
239
        StartHeight int64
240
        EndHeight   int64
241
}
242

243
func (q *Queries) DeletePruneLogEntriesInRange(ctx context.Context, arg DeletePruneLogEntriesInRangeParams) error {
×
244
        _, err := q.db.ExecContext(ctx, deletePruneLogEntriesInRange, arg.StartHeight, arg.EndHeight)
×
245
        return err
×
246
}
×
247

248
const deleteUnconnectedNodes = `-- name: DeleteUnconnectedNodes :many
249
DELETE FROM graph_nodes
250
WHERE
251
    -- Ignore any of our source nodes.
252
    NOT EXISTS (
253
        SELECT 1
254
        FROM graph_source_nodes sn
255
        WHERE sn.node_id = graph_nodes.id
256
    )
257
    -- Select all nodes that do not have any channels.
258
    AND NOT EXISTS (
259
        SELECT 1
260
        FROM graph_channels c
261
        WHERE c.node_id_1 = graph_nodes.id OR c.node_id_2 = graph_nodes.id
262
) RETURNING pub_key
263
`
264

265
func (q *Queries) DeleteUnconnectedNodes(ctx context.Context) ([][]byte, error) {
×
266
        rows, err := q.db.QueryContext(ctx, deleteUnconnectedNodes)
×
267
        if err != nil {
×
268
                return nil, err
×
269
        }
×
270
        defer rows.Close()
×
271
        var items [][]byte
×
272
        for rows.Next() {
×
273
                var pub_key []byte
×
274
                if err := rows.Scan(&pub_key); err != nil {
×
275
                        return nil, err
×
276
                }
×
277
                items = append(items, pub_key)
×
278
        }
279
        if err := rows.Close(); err != nil {
×
280
                return nil, err
×
281
        }
×
282
        if err := rows.Err(); err != nil {
×
283
                return nil, err
×
284
        }
×
285
        return items, nil
×
286
}
287

288
const deleteZombieChannel = `-- name: DeleteZombieChannel :execresult
289
DELETE FROM graph_zombie_channels
290
WHERE scid = $1
291
AND version = $2
292
`
293

294
type DeleteZombieChannelParams struct {
295
        Scid    []byte
296
        Version int16
297
}
298

299
func (q *Queries) DeleteZombieChannel(ctx context.Context, arg DeleteZombieChannelParams) (sql.Result, error) {
×
300
        return q.db.ExecContext(ctx, deleteZombieChannel, arg.Scid, arg.Version)
×
301
}
×
302

303
const getChannelAndNodesBySCID = `-- name: GetChannelAndNodesBySCID :one
304
SELECT
305
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
306
    n1.pub_key AS node1_pub_key,
307
    n2.pub_key AS node2_pub_key
308
FROM graph_channels c
309
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
310
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
311
WHERE c.scid = $1
312
  AND c.version = $2
313
`
314

315
type GetChannelAndNodesBySCIDParams struct {
316
        Scid    []byte
317
        Version int16
318
}
319

320
type GetChannelAndNodesBySCIDRow struct {
321
        ID                int64
322
        Version           int16
323
        Scid              []byte
324
        NodeID1           int64
325
        NodeID2           int64
326
        Outpoint          string
327
        Capacity          sql.NullInt64
328
        BitcoinKey1       []byte
329
        BitcoinKey2       []byte
330
        Node1Signature    []byte
331
        Node2Signature    []byte
332
        Bitcoin1Signature []byte
333
        Bitcoin2Signature []byte
334
        Node1PubKey       []byte
335
        Node2PubKey       []byte
336
}
337

338
func (q *Queries) GetChannelAndNodesBySCID(ctx context.Context, arg GetChannelAndNodesBySCIDParams) (GetChannelAndNodesBySCIDRow, error) {
×
339
        row := q.db.QueryRowContext(ctx, getChannelAndNodesBySCID, arg.Scid, arg.Version)
×
340
        var i GetChannelAndNodesBySCIDRow
×
341
        err := row.Scan(
×
342
                &i.ID,
×
343
                &i.Version,
×
344
                &i.Scid,
×
345
                &i.NodeID1,
×
346
                &i.NodeID2,
×
347
                &i.Outpoint,
×
348
                &i.Capacity,
×
349
                &i.BitcoinKey1,
×
350
                &i.BitcoinKey2,
×
351
                &i.Node1Signature,
×
352
                &i.Node2Signature,
×
353
                &i.Bitcoin1Signature,
×
354
                &i.Bitcoin2Signature,
×
355
                &i.Node1PubKey,
×
356
                &i.Node2PubKey,
×
357
        )
×
358
        return i, err
×
359
}
×
360

361
const getChannelByOutpointWithPolicies = `-- name: GetChannelByOutpointWithPolicies :one
362
SELECT
363
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
364

365
    n1.pub_key AS node1_pubkey,
366
    n2.pub_key AS node2_pubkey,
367

368
    -- Node 1 policy
369
    cp1.id AS policy_1_id,
370
    cp1.node_id AS policy_1_node_id,
371
    cp1.version AS policy_1_version,
372
    cp1.timelock AS policy_1_timelock,
373
    cp1.fee_ppm AS policy_1_fee_ppm,
374
    cp1.base_fee_msat AS policy_1_base_fee_msat,
375
    cp1.min_htlc_msat AS policy_1_min_htlc_msat,
376
    cp1.max_htlc_msat AS policy_1_max_htlc_msat,
377
    cp1.last_update AS policy_1_last_update,
378
    cp1.disabled AS policy_1_disabled,
379
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
380
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
381
    cp1.message_flags AS policy_1_message_flags,
382
    cp1.channel_flags AS policy_1_channel_flags,
383
    cp1.signature AS policy_1_signature,
384

385
    -- Node 2 policy
386
    cp2.id AS policy_2_id,
387
    cp2.node_id AS policy_2_node_id,
388
    cp2.version AS policy_2_version,
389
    cp2.timelock AS policy_2_timelock,
390
    cp2.fee_ppm AS policy_2_fee_ppm,
391
    cp2.base_fee_msat AS policy_2_base_fee_msat,
392
    cp2.min_htlc_msat AS policy_2_min_htlc_msat,
393
    cp2.max_htlc_msat AS policy_2_max_htlc_msat,
394
    cp2.last_update AS policy_2_last_update,
395
    cp2.disabled AS policy_2_disabled,
396
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
397
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
398
    cp2.message_flags AS policy_2_message_flags,
399
    cp2.channel_flags AS policy_2_channel_flags,
400
    cp2.signature AS policy_2_signature
401
FROM graph_channels c
402
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
403
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
404
    LEFT JOIN graph_channel_policies cp1
405
        ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
406
    LEFT JOIN graph_channel_policies cp2
407
        ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
408
WHERE c.outpoint = $1 AND c.version = $2
409
`
410

411
type GetChannelByOutpointWithPoliciesParams struct {
412
        Outpoint string
413
        Version  int16
414
}
415

416
type GetChannelByOutpointWithPoliciesRow struct {
417
        GraphChannel                   GraphChannel
418
        Node1Pubkey                    []byte
419
        Node2Pubkey                    []byte
420
        Policy1ID                      sql.NullInt64
421
        Policy1NodeID                  sql.NullInt64
422
        Policy1Version                 sql.NullInt16
423
        Policy1Timelock                sql.NullInt32
424
        Policy1FeePpm                  sql.NullInt64
425
        Policy1BaseFeeMsat             sql.NullInt64
426
        Policy1MinHtlcMsat             sql.NullInt64
427
        Policy1MaxHtlcMsat             sql.NullInt64
428
        Policy1LastUpdate              sql.NullInt64
429
        Policy1Disabled                sql.NullBool
430
        Policy1InboundBaseFeeMsat      sql.NullInt64
431
        Policy1InboundFeeRateMilliMsat sql.NullInt64
432
        Policy1MessageFlags            sql.NullInt16
433
        Policy1ChannelFlags            sql.NullInt16
434
        Policy1Signature               []byte
435
        Policy2ID                      sql.NullInt64
436
        Policy2NodeID                  sql.NullInt64
437
        Policy2Version                 sql.NullInt16
438
        Policy2Timelock                sql.NullInt32
439
        Policy2FeePpm                  sql.NullInt64
440
        Policy2BaseFeeMsat             sql.NullInt64
441
        Policy2MinHtlcMsat             sql.NullInt64
442
        Policy2MaxHtlcMsat             sql.NullInt64
443
        Policy2LastUpdate              sql.NullInt64
444
        Policy2Disabled                sql.NullBool
445
        Policy2InboundBaseFeeMsat      sql.NullInt64
446
        Policy2InboundFeeRateMilliMsat sql.NullInt64
447
        Policy2MessageFlags            sql.NullInt16
448
        Policy2ChannelFlags            sql.NullInt16
449
        Policy2Signature               []byte
450
}
451

452
func (q *Queries) GetChannelByOutpointWithPolicies(ctx context.Context, arg GetChannelByOutpointWithPoliciesParams) (GetChannelByOutpointWithPoliciesRow, error) {
×
453
        row := q.db.QueryRowContext(ctx, getChannelByOutpointWithPolicies, arg.Outpoint, arg.Version)
×
454
        var i GetChannelByOutpointWithPoliciesRow
×
455
        err := row.Scan(
×
456
                &i.GraphChannel.ID,
×
457
                &i.GraphChannel.Version,
×
458
                &i.GraphChannel.Scid,
×
459
                &i.GraphChannel.NodeID1,
×
460
                &i.GraphChannel.NodeID2,
×
461
                &i.GraphChannel.Outpoint,
×
462
                &i.GraphChannel.Capacity,
×
463
                &i.GraphChannel.BitcoinKey1,
×
464
                &i.GraphChannel.BitcoinKey2,
×
465
                &i.GraphChannel.Node1Signature,
×
466
                &i.GraphChannel.Node2Signature,
×
467
                &i.GraphChannel.Bitcoin1Signature,
×
468
                &i.GraphChannel.Bitcoin2Signature,
×
469
                &i.Node1Pubkey,
×
470
                &i.Node2Pubkey,
×
471
                &i.Policy1ID,
×
472
                &i.Policy1NodeID,
×
473
                &i.Policy1Version,
×
474
                &i.Policy1Timelock,
×
475
                &i.Policy1FeePpm,
×
476
                &i.Policy1BaseFeeMsat,
×
477
                &i.Policy1MinHtlcMsat,
×
478
                &i.Policy1MaxHtlcMsat,
×
479
                &i.Policy1LastUpdate,
×
480
                &i.Policy1Disabled,
×
481
                &i.Policy1InboundBaseFeeMsat,
×
482
                &i.Policy1InboundFeeRateMilliMsat,
×
483
                &i.Policy1MessageFlags,
×
484
                &i.Policy1ChannelFlags,
×
485
                &i.Policy1Signature,
×
486
                &i.Policy2ID,
×
487
                &i.Policy2NodeID,
×
488
                &i.Policy2Version,
×
489
                &i.Policy2Timelock,
×
490
                &i.Policy2FeePpm,
×
491
                &i.Policy2BaseFeeMsat,
×
492
                &i.Policy2MinHtlcMsat,
×
493
                &i.Policy2MaxHtlcMsat,
×
494
                &i.Policy2LastUpdate,
×
495
                &i.Policy2Disabled,
×
496
                &i.Policy2InboundBaseFeeMsat,
×
497
                &i.Policy2InboundFeeRateMilliMsat,
×
498
                &i.Policy2MessageFlags,
×
499
                &i.Policy2ChannelFlags,
×
500
                &i.Policy2Signature,
×
501
        )
×
502
        return i, err
×
503
}
×
504

505
const getChannelBySCID = `-- name: GetChannelBySCID :one
506
SELECT id, version, scid, node_id_1, node_id_2, outpoint, capacity, bitcoin_key_1, bitcoin_key_2, node_1_signature, node_2_signature, bitcoin_1_signature, bitcoin_2_signature FROM graph_channels
507
WHERE scid = $1 AND version = $2
508
`
509

510
type GetChannelBySCIDParams struct {
511
        Scid    []byte
512
        Version int16
513
}
514

515
func (q *Queries) GetChannelBySCID(ctx context.Context, arg GetChannelBySCIDParams) (GraphChannel, error) {
×
516
        row := q.db.QueryRowContext(ctx, getChannelBySCID, arg.Scid, arg.Version)
×
517
        var i GraphChannel
×
518
        err := row.Scan(
×
519
                &i.ID,
×
520
                &i.Version,
×
521
                &i.Scid,
×
522
                &i.NodeID1,
×
523
                &i.NodeID2,
×
524
                &i.Outpoint,
×
525
                &i.Capacity,
×
526
                &i.BitcoinKey1,
×
527
                &i.BitcoinKey2,
×
528
                &i.Node1Signature,
×
529
                &i.Node2Signature,
×
530
                &i.Bitcoin1Signature,
×
531
                &i.Bitcoin2Signature,
×
532
        )
×
533
        return i, err
×
534
}
×
535

536
const getChannelBySCIDWithPolicies = `-- name: GetChannelBySCIDWithPolicies :one
537
SELECT
538
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
539
    n1.id, n1.version, n1.pub_key, n1.alias, n1.last_update, n1.color, n1.signature,
540
    n2.id, n2.version, n2.pub_key, n2.alias, n2.last_update, n2.color, n2.signature,
541

542
    -- Policy 1
543
    cp1.id AS policy1_id,
544
    cp1.node_id AS policy1_node_id,
545
    cp1.version AS policy1_version,
546
    cp1.timelock AS policy1_timelock,
547
    cp1.fee_ppm AS policy1_fee_ppm,
548
    cp1.base_fee_msat AS policy1_base_fee_msat,
549
    cp1.min_htlc_msat AS policy1_min_htlc_msat,
550
    cp1.max_htlc_msat AS policy1_max_htlc_msat,
551
    cp1.last_update AS policy1_last_update,
552
    cp1.disabled AS policy1_disabled,
553
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
554
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
555
    cp1.message_flags AS policy1_message_flags,
556
    cp1.channel_flags AS policy1_channel_flags,
557
    cp1.signature AS policy1_signature,
558

559
    -- Policy 2
560
    cp2.id AS policy2_id,
561
    cp2.node_id AS policy2_node_id,
562
    cp2.version AS policy2_version,
563
    cp2.timelock AS policy2_timelock,
564
    cp2.fee_ppm AS policy2_fee_ppm,
565
    cp2.base_fee_msat AS policy2_base_fee_msat,
566
    cp2.min_htlc_msat AS policy2_min_htlc_msat,
567
    cp2.max_htlc_msat AS policy2_max_htlc_msat,
568
    cp2.last_update AS policy2_last_update,
569
    cp2.disabled AS policy2_disabled,
570
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
571
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
572
    cp2.message_flags AS policy_2_message_flags,
573
    cp2.channel_flags AS policy_2_channel_flags,
574
    cp2.signature AS policy2_signature
575

576
FROM graph_channels c
577
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
578
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
579
    LEFT JOIN graph_channel_policies cp1
580
        ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
581
    LEFT JOIN graph_channel_policies cp2
582
        ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
583
WHERE c.scid = $1
584
  AND c.version = $2
585
`
586

587
type GetChannelBySCIDWithPoliciesParams struct {
588
        Scid    []byte
589
        Version int16
590
}
591

592
type GetChannelBySCIDWithPoliciesRow struct {
593
        GraphChannel                   GraphChannel
594
        GraphNode                      GraphNode
595
        GraphNode_2                    GraphNode
596
        Policy1ID                      sql.NullInt64
597
        Policy1NodeID                  sql.NullInt64
598
        Policy1Version                 sql.NullInt16
599
        Policy1Timelock                sql.NullInt32
600
        Policy1FeePpm                  sql.NullInt64
601
        Policy1BaseFeeMsat             sql.NullInt64
602
        Policy1MinHtlcMsat             sql.NullInt64
603
        Policy1MaxHtlcMsat             sql.NullInt64
604
        Policy1LastUpdate              sql.NullInt64
605
        Policy1Disabled                sql.NullBool
606
        Policy1InboundBaseFeeMsat      sql.NullInt64
607
        Policy1InboundFeeRateMilliMsat sql.NullInt64
608
        Policy1MessageFlags            sql.NullInt16
609
        Policy1ChannelFlags            sql.NullInt16
610
        Policy1Signature               []byte
611
        Policy2ID                      sql.NullInt64
612
        Policy2NodeID                  sql.NullInt64
613
        Policy2Version                 sql.NullInt16
614
        Policy2Timelock                sql.NullInt32
615
        Policy2FeePpm                  sql.NullInt64
616
        Policy2BaseFeeMsat             sql.NullInt64
617
        Policy2MinHtlcMsat             sql.NullInt64
618
        Policy2MaxHtlcMsat             sql.NullInt64
619
        Policy2LastUpdate              sql.NullInt64
620
        Policy2Disabled                sql.NullBool
621
        Policy2InboundBaseFeeMsat      sql.NullInt64
622
        Policy2InboundFeeRateMilliMsat sql.NullInt64
623
        Policy2MessageFlags            sql.NullInt16
624
        Policy2ChannelFlags            sql.NullInt16
625
        Policy2Signature               []byte
626
}
627

628
func (q *Queries) GetChannelBySCIDWithPolicies(ctx context.Context, arg GetChannelBySCIDWithPoliciesParams) (GetChannelBySCIDWithPoliciesRow, error) {
×
629
        row := q.db.QueryRowContext(ctx, getChannelBySCIDWithPolicies, arg.Scid, arg.Version)
×
630
        var i GetChannelBySCIDWithPoliciesRow
×
631
        err := row.Scan(
×
632
                &i.GraphChannel.ID,
×
633
                &i.GraphChannel.Version,
×
634
                &i.GraphChannel.Scid,
×
635
                &i.GraphChannel.NodeID1,
×
636
                &i.GraphChannel.NodeID2,
×
637
                &i.GraphChannel.Outpoint,
×
638
                &i.GraphChannel.Capacity,
×
639
                &i.GraphChannel.BitcoinKey1,
×
640
                &i.GraphChannel.BitcoinKey2,
×
641
                &i.GraphChannel.Node1Signature,
×
642
                &i.GraphChannel.Node2Signature,
×
643
                &i.GraphChannel.Bitcoin1Signature,
×
644
                &i.GraphChannel.Bitcoin2Signature,
×
645
                &i.GraphNode.ID,
×
646
                &i.GraphNode.Version,
×
647
                &i.GraphNode.PubKey,
×
648
                &i.GraphNode.Alias,
×
649
                &i.GraphNode.LastUpdate,
×
650
                &i.GraphNode.Color,
×
651
                &i.GraphNode.Signature,
×
652
                &i.GraphNode_2.ID,
×
653
                &i.GraphNode_2.Version,
×
654
                &i.GraphNode_2.PubKey,
×
655
                &i.GraphNode_2.Alias,
×
656
                &i.GraphNode_2.LastUpdate,
×
657
                &i.GraphNode_2.Color,
×
658
                &i.GraphNode_2.Signature,
×
659
                &i.Policy1ID,
×
660
                &i.Policy1NodeID,
×
661
                &i.Policy1Version,
×
662
                &i.Policy1Timelock,
×
663
                &i.Policy1FeePpm,
×
664
                &i.Policy1BaseFeeMsat,
×
665
                &i.Policy1MinHtlcMsat,
×
666
                &i.Policy1MaxHtlcMsat,
×
667
                &i.Policy1LastUpdate,
×
668
                &i.Policy1Disabled,
×
669
                &i.Policy1InboundBaseFeeMsat,
×
670
                &i.Policy1InboundFeeRateMilliMsat,
×
671
                &i.Policy1MessageFlags,
×
672
                &i.Policy1ChannelFlags,
×
673
                &i.Policy1Signature,
×
674
                &i.Policy2ID,
×
675
                &i.Policy2NodeID,
×
676
                &i.Policy2Version,
×
677
                &i.Policy2Timelock,
×
678
                &i.Policy2FeePpm,
×
679
                &i.Policy2BaseFeeMsat,
×
680
                &i.Policy2MinHtlcMsat,
×
681
                &i.Policy2MaxHtlcMsat,
×
682
                &i.Policy2LastUpdate,
×
683
                &i.Policy2Disabled,
×
684
                &i.Policy2InboundBaseFeeMsat,
×
685
                &i.Policy2InboundFeeRateMilliMsat,
×
686
                &i.Policy2MessageFlags,
×
687
                &i.Policy2ChannelFlags,
×
688
                &i.Policy2Signature,
×
689
        )
×
690
        return i, err
×
691
}
×
692

693
const getChannelFeaturesAndExtras = `-- name: GetChannelFeaturesAndExtras :many
694
SELECT
695
    cf.channel_id,
696
    true AS is_feature,
697
    cf.feature_bit AS feature_bit,
698
    NULL AS extra_key,
699
    NULL AS value
700
FROM graph_channel_features cf
701
WHERE cf.channel_id = $1
702

703
UNION ALL
704

705
SELECT
706
    cet.channel_id,
707
    false AS is_feature,
708
    0 AS feature_bit,
709
    cet.type AS extra_key,
710
    cet.value AS value
711
FROM graph_channel_extra_types cet
712
WHERE cet.channel_id = $1
713
`
714

715
type GetChannelFeaturesAndExtrasRow struct {
716
        ChannelID  int64
717
        IsFeature  bool
718
        FeatureBit int32
719
        ExtraKey   interface{}
720
        Value      interface{}
721
}
722

723
func (q *Queries) GetChannelFeaturesAndExtras(ctx context.Context, channelID int64) ([]GetChannelFeaturesAndExtrasRow, error) {
×
724
        rows, err := q.db.QueryContext(ctx, getChannelFeaturesAndExtras, channelID)
×
725
        if err != nil {
×
726
                return nil, err
×
727
        }
×
728
        defer rows.Close()
×
729
        var items []GetChannelFeaturesAndExtrasRow
×
730
        for rows.Next() {
×
731
                var i GetChannelFeaturesAndExtrasRow
×
732
                if err := rows.Scan(
×
733
                        &i.ChannelID,
×
734
                        &i.IsFeature,
×
735
                        &i.FeatureBit,
×
736
                        &i.ExtraKey,
×
737
                        &i.Value,
×
738
                ); err != nil {
×
739
                        return nil, err
×
740
                }
×
741
                items = append(items, i)
×
742
        }
743
        if err := rows.Close(); err != nil {
×
744
                return nil, err
×
745
        }
×
746
        if err := rows.Err(); err != nil {
×
747
                return nil, err
×
748
        }
×
749
        return items, nil
×
750
}
751

752
const getChannelPolicyByChannelAndNode = `-- name: GetChannelPolicyByChannelAndNode :one
753
SELECT id, version, channel_id, node_id, timelock, fee_ppm, base_fee_msat, min_htlc_msat, max_htlc_msat, last_update, disabled, inbound_base_fee_msat, inbound_fee_rate_milli_msat, message_flags, channel_flags, signature
754
FROM graph_channel_policies
755
WHERE channel_id = $1
756
  AND node_id = $2
757
  AND version = $3
758
`
759

760
type GetChannelPolicyByChannelAndNodeParams struct {
761
        ChannelID int64
762
        NodeID    int64
763
        Version   int16
764
}
765

766
func (q *Queries) GetChannelPolicyByChannelAndNode(ctx context.Context, arg GetChannelPolicyByChannelAndNodeParams) (GraphChannelPolicy, error) {
×
767
        row := q.db.QueryRowContext(ctx, getChannelPolicyByChannelAndNode, arg.ChannelID, arg.NodeID, arg.Version)
×
768
        var i GraphChannelPolicy
×
769
        err := row.Scan(
×
770
                &i.ID,
×
771
                &i.Version,
×
772
                &i.ChannelID,
×
773
                &i.NodeID,
×
774
                &i.Timelock,
×
775
                &i.FeePpm,
×
776
                &i.BaseFeeMsat,
×
777
                &i.MinHtlcMsat,
×
778
                &i.MaxHtlcMsat,
×
779
                &i.LastUpdate,
×
780
                &i.Disabled,
×
781
                &i.InboundBaseFeeMsat,
×
782
                &i.InboundFeeRateMilliMsat,
×
783
                &i.MessageFlags,
×
784
                &i.ChannelFlags,
×
785
                &i.Signature,
×
786
        )
×
787
        return i, err
×
788
}
×
789

790
const getChannelPolicyExtraTypes = `-- name: GetChannelPolicyExtraTypes :many
791
SELECT
792
    cp.id AS policy_id,
793
    cp.channel_id,
794
    cp.node_id,
795
    cpet.type,
796
    cpet.value
797
FROM graph_channel_policies cp
798
JOIN graph_channel_policy_extra_types cpet
799
ON cp.id = cpet.channel_policy_id
800
WHERE cp.id = $1 OR cp.id = $2
801
`
802

803
type GetChannelPolicyExtraTypesParams struct {
804
        ID   int64
805
        ID_2 int64
806
}
807

808
type GetChannelPolicyExtraTypesRow struct {
809
        PolicyID  int64
810
        ChannelID int64
811
        NodeID    int64
812
        Type      int64
813
        Value     []byte
814
}
815

816
func (q *Queries) GetChannelPolicyExtraTypes(ctx context.Context, arg GetChannelPolicyExtraTypesParams) ([]GetChannelPolicyExtraTypesRow, error) {
×
817
        rows, err := q.db.QueryContext(ctx, getChannelPolicyExtraTypes, arg.ID, arg.ID_2)
×
818
        if err != nil {
×
819
                return nil, err
×
820
        }
×
821
        defer rows.Close()
×
822
        var items []GetChannelPolicyExtraTypesRow
×
823
        for rows.Next() {
×
824
                var i GetChannelPolicyExtraTypesRow
×
825
                if err := rows.Scan(
×
826
                        &i.PolicyID,
×
827
                        &i.ChannelID,
×
828
                        &i.NodeID,
×
829
                        &i.Type,
×
830
                        &i.Value,
×
831
                ); err != nil {
×
832
                        return nil, err
×
833
                }
×
834
                items = append(items, i)
×
835
        }
836
        if err := rows.Close(); err != nil {
×
837
                return nil, err
×
838
        }
×
839
        if err := rows.Err(); err != nil {
×
840
                return nil, err
×
841
        }
×
842
        return items, nil
×
843
}
844

845
const getChannelsByOutpoints = `-- name: GetChannelsByOutpoints :many
846
SELECT
847
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
848
    n1.pub_key AS node1_pubkey,
849
    n2.pub_key AS node2_pubkey
850
FROM graph_channels c
851
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
852
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
853
WHERE c.outpoint IN
854
    (/*SLICE:outpoints*/?)
855
`
856

857
type GetChannelsByOutpointsRow struct {
858
        GraphChannel GraphChannel
859
        Node1Pubkey  []byte
860
        Node2Pubkey  []byte
861
}
862

NEW
863
func (q *Queries) GetChannelsByOutpoints(ctx context.Context, outpoints []string) ([]GetChannelsByOutpointsRow, error) {
×
NEW
864
        query := getChannelsByOutpoints
×
NEW
865
        var queryParams []interface{}
×
NEW
866
        if len(outpoints) > 0 {
×
NEW
867
                for _, v := range outpoints {
×
NEW
868
                        queryParams = append(queryParams, v)
×
NEW
869
                }
×
NEW
870
                query = strings.Replace(query, "/*SLICE:outpoints*/?", makeQueryParams(len(queryParams), len(outpoints)), 1)
×
NEW
871
        } else {
×
NEW
872
                query = strings.Replace(query, "/*SLICE:outpoints*/?", "NULL", 1)
×
NEW
873
        }
×
NEW
874
        rows, err := q.db.QueryContext(ctx, query, queryParams...)
×
NEW
875
        if err != nil {
×
NEW
876
                return nil, err
×
NEW
877
        }
×
NEW
878
        defer rows.Close()
×
NEW
879
        var items []GetChannelsByOutpointsRow
×
NEW
880
        for rows.Next() {
×
NEW
881
                var i GetChannelsByOutpointsRow
×
NEW
882
                if err := rows.Scan(
×
NEW
883
                        &i.GraphChannel.ID,
×
NEW
884
                        &i.GraphChannel.Version,
×
NEW
885
                        &i.GraphChannel.Scid,
×
NEW
886
                        &i.GraphChannel.NodeID1,
×
NEW
887
                        &i.GraphChannel.NodeID2,
×
NEW
888
                        &i.GraphChannel.Outpoint,
×
NEW
889
                        &i.GraphChannel.Capacity,
×
NEW
890
                        &i.GraphChannel.BitcoinKey1,
×
NEW
891
                        &i.GraphChannel.BitcoinKey2,
×
NEW
892
                        &i.GraphChannel.Node1Signature,
×
NEW
893
                        &i.GraphChannel.Node2Signature,
×
NEW
894
                        &i.GraphChannel.Bitcoin1Signature,
×
NEW
895
                        &i.GraphChannel.Bitcoin2Signature,
×
NEW
896
                        &i.Node1Pubkey,
×
NEW
897
                        &i.Node2Pubkey,
×
NEW
898
                ); err != nil {
×
NEW
899
                        return nil, err
×
NEW
900
                }
×
NEW
901
                items = append(items, i)
×
902
        }
NEW
903
        if err := rows.Close(); err != nil {
×
NEW
904
                return nil, err
×
NEW
905
        }
×
NEW
906
        if err := rows.Err(); err != nil {
×
NEW
907
                return nil, err
×
NEW
908
        }
×
NEW
909
        return items, nil
×
910
}
911

912
const getChannelsByPolicyLastUpdateRange = `-- name: GetChannelsByPolicyLastUpdateRange :many
913
SELECT
914
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
915
    n1.id, n1.version, n1.pub_key, n1.alias, n1.last_update, n1.color, n1.signature,
916
    n2.id, n2.version, n2.pub_key, n2.alias, n2.last_update, n2.color, n2.signature,
917

918
    -- Policy 1 (node_id_1)
919
    cp1.id AS policy1_id,
920
    cp1.node_id AS policy1_node_id,
921
    cp1.version AS policy1_version,
922
    cp1.timelock AS policy1_timelock,
923
    cp1.fee_ppm AS policy1_fee_ppm,
924
    cp1.base_fee_msat AS policy1_base_fee_msat,
925
    cp1.min_htlc_msat AS policy1_min_htlc_msat,
926
    cp1.max_htlc_msat AS policy1_max_htlc_msat,
927
    cp1.last_update AS policy1_last_update,
928
    cp1.disabled AS policy1_disabled,
929
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
930
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
931
    cp1.message_flags AS policy1_message_flags,
932
    cp1.channel_flags AS policy1_channel_flags,
933
    cp1.signature AS policy1_signature,
934

935
    -- Policy 2 (node_id_2)
936
    cp2.id AS policy2_id,
937
    cp2.node_id AS policy2_node_id,
938
    cp2.version AS policy2_version,
939
    cp2.timelock AS policy2_timelock,
940
    cp2.fee_ppm AS policy2_fee_ppm,
941
    cp2.base_fee_msat AS policy2_base_fee_msat,
942
    cp2.min_htlc_msat AS policy2_min_htlc_msat,
943
    cp2.max_htlc_msat AS policy2_max_htlc_msat,
944
    cp2.last_update AS policy2_last_update,
945
    cp2.disabled AS policy2_disabled,
946
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
947
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
948
    cp2.message_flags AS policy2_message_flags,
949
    cp2.channel_flags AS policy2_channel_flags,
950
    cp2.signature AS policy2_signature
951

952
FROM graph_channels c
953
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
954
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
955
    LEFT JOIN graph_channel_policies cp1
956
        ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
957
    LEFT JOIN graph_channel_policies cp2
958
        ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
959
WHERE c.version = $1
960
  AND (
961
       (cp1.last_update >= $2 AND cp1.last_update < $3)
962
       OR
963
       (cp2.last_update >= $2 AND cp2.last_update < $3)
964
  )
965
ORDER BY
966
    CASE
967
        WHEN COALESCE(cp1.last_update, 0) >= COALESCE(cp2.last_update, 0)
968
            THEN COALESCE(cp1.last_update, 0)
969
        ELSE COALESCE(cp2.last_update, 0)
970
        END ASC
971
`
972

973
type GetChannelsByPolicyLastUpdateRangeParams struct {
974
        Version   int16
975
        StartTime sql.NullInt64
976
        EndTime   sql.NullInt64
977
}
978

979
type GetChannelsByPolicyLastUpdateRangeRow struct {
980
        GraphChannel                   GraphChannel
981
        GraphNode                      GraphNode
982
        GraphNode_2                    GraphNode
983
        Policy1ID                      sql.NullInt64
984
        Policy1NodeID                  sql.NullInt64
985
        Policy1Version                 sql.NullInt16
986
        Policy1Timelock                sql.NullInt32
987
        Policy1FeePpm                  sql.NullInt64
988
        Policy1BaseFeeMsat             sql.NullInt64
989
        Policy1MinHtlcMsat             sql.NullInt64
990
        Policy1MaxHtlcMsat             sql.NullInt64
991
        Policy1LastUpdate              sql.NullInt64
992
        Policy1Disabled                sql.NullBool
993
        Policy1InboundBaseFeeMsat      sql.NullInt64
994
        Policy1InboundFeeRateMilliMsat sql.NullInt64
995
        Policy1MessageFlags            sql.NullInt16
996
        Policy1ChannelFlags            sql.NullInt16
997
        Policy1Signature               []byte
998
        Policy2ID                      sql.NullInt64
999
        Policy2NodeID                  sql.NullInt64
1000
        Policy2Version                 sql.NullInt16
1001
        Policy2Timelock                sql.NullInt32
1002
        Policy2FeePpm                  sql.NullInt64
1003
        Policy2BaseFeeMsat             sql.NullInt64
1004
        Policy2MinHtlcMsat             sql.NullInt64
1005
        Policy2MaxHtlcMsat             sql.NullInt64
1006
        Policy2LastUpdate              sql.NullInt64
1007
        Policy2Disabled                sql.NullBool
1008
        Policy2InboundBaseFeeMsat      sql.NullInt64
1009
        Policy2InboundFeeRateMilliMsat sql.NullInt64
1010
        Policy2MessageFlags            sql.NullInt16
1011
        Policy2ChannelFlags            sql.NullInt16
1012
        Policy2Signature               []byte
1013
}
1014

1015
func (q *Queries) GetChannelsByPolicyLastUpdateRange(ctx context.Context, arg GetChannelsByPolicyLastUpdateRangeParams) ([]GetChannelsByPolicyLastUpdateRangeRow, error) {
×
1016
        rows, err := q.db.QueryContext(ctx, getChannelsByPolicyLastUpdateRange, arg.Version, arg.StartTime, arg.EndTime)
×
1017
        if err != nil {
×
1018
                return nil, err
×
1019
        }
×
1020
        defer rows.Close()
×
1021
        var items []GetChannelsByPolicyLastUpdateRangeRow
×
1022
        for rows.Next() {
×
1023
                var i GetChannelsByPolicyLastUpdateRangeRow
×
1024
                if err := rows.Scan(
×
1025
                        &i.GraphChannel.ID,
×
1026
                        &i.GraphChannel.Version,
×
1027
                        &i.GraphChannel.Scid,
×
1028
                        &i.GraphChannel.NodeID1,
×
1029
                        &i.GraphChannel.NodeID2,
×
1030
                        &i.GraphChannel.Outpoint,
×
1031
                        &i.GraphChannel.Capacity,
×
1032
                        &i.GraphChannel.BitcoinKey1,
×
1033
                        &i.GraphChannel.BitcoinKey2,
×
1034
                        &i.GraphChannel.Node1Signature,
×
1035
                        &i.GraphChannel.Node2Signature,
×
1036
                        &i.GraphChannel.Bitcoin1Signature,
×
1037
                        &i.GraphChannel.Bitcoin2Signature,
×
1038
                        &i.GraphNode.ID,
×
1039
                        &i.GraphNode.Version,
×
1040
                        &i.GraphNode.PubKey,
×
1041
                        &i.GraphNode.Alias,
×
1042
                        &i.GraphNode.LastUpdate,
×
1043
                        &i.GraphNode.Color,
×
1044
                        &i.GraphNode.Signature,
×
1045
                        &i.GraphNode_2.ID,
×
1046
                        &i.GraphNode_2.Version,
×
1047
                        &i.GraphNode_2.PubKey,
×
1048
                        &i.GraphNode_2.Alias,
×
1049
                        &i.GraphNode_2.LastUpdate,
×
1050
                        &i.GraphNode_2.Color,
×
1051
                        &i.GraphNode_2.Signature,
×
1052
                        &i.Policy1ID,
×
1053
                        &i.Policy1NodeID,
×
1054
                        &i.Policy1Version,
×
1055
                        &i.Policy1Timelock,
×
1056
                        &i.Policy1FeePpm,
×
1057
                        &i.Policy1BaseFeeMsat,
×
1058
                        &i.Policy1MinHtlcMsat,
×
1059
                        &i.Policy1MaxHtlcMsat,
×
1060
                        &i.Policy1LastUpdate,
×
1061
                        &i.Policy1Disabled,
×
1062
                        &i.Policy1InboundBaseFeeMsat,
×
1063
                        &i.Policy1InboundFeeRateMilliMsat,
×
1064
                        &i.Policy1MessageFlags,
×
1065
                        &i.Policy1ChannelFlags,
×
1066
                        &i.Policy1Signature,
×
1067
                        &i.Policy2ID,
×
1068
                        &i.Policy2NodeID,
×
1069
                        &i.Policy2Version,
×
1070
                        &i.Policy2Timelock,
×
1071
                        &i.Policy2FeePpm,
×
1072
                        &i.Policy2BaseFeeMsat,
×
1073
                        &i.Policy2MinHtlcMsat,
×
1074
                        &i.Policy2MaxHtlcMsat,
×
1075
                        &i.Policy2LastUpdate,
×
1076
                        &i.Policy2Disabled,
×
1077
                        &i.Policy2InboundBaseFeeMsat,
×
1078
                        &i.Policy2InboundFeeRateMilliMsat,
×
1079
                        &i.Policy2MessageFlags,
×
1080
                        &i.Policy2ChannelFlags,
×
1081
                        &i.Policy2Signature,
×
1082
                ); err != nil {
×
1083
                        return nil, err
×
1084
                }
×
1085
                items = append(items, i)
×
1086
        }
1087
        if err := rows.Close(); err != nil {
×
1088
                return nil, err
×
1089
        }
×
1090
        if err := rows.Err(); err != nil {
×
1091
                return nil, err
×
1092
        }
×
1093
        return items, nil
×
1094
}
1095

1096
const getChannelsBySCIDRange = `-- name: GetChannelsBySCIDRange :many
1097
SELECT c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
1098
    n1.pub_key AS node1_pub_key,
1099
    n2.pub_key AS node2_pub_key
1100
FROM graph_channels c
1101
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
1102
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
1103
WHERE scid >= $1
1104
  AND scid < $2
1105
`
1106

1107
type GetChannelsBySCIDRangeParams struct {
1108
        StartScid []byte
1109
        EndScid   []byte
1110
}
1111

1112
type GetChannelsBySCIDRangeRow struct {
1113
        GraphChannel GraphChannel
1114
        Node1PubKey  []byte
1115
        Node2PubKey  []byte
1116
}
1117

1118
func (q *Queries) GetChannelsBySCIDRange(ctx context.Context, arg GetChannelsBySCIDRangeParams) ([]GetChannelsBySCIDRangeRow, error) {
×
1119
        rows, err := q.db.QueryContext(ctx, getChannelsBySCIDRange, arg.StartScid, arg.EndScid)
×
1120
        if err != nil {
×
1121
                return nil, err
×
1122
        }
×
1123
        defer rows.Close()
×
1124
        var items []GetChannelsBySCIDRangeRow
×
1125
        for rows.Next() {
×
1126
                var i GetChannelsBySCIDRangeRow
×
1127
                if err := rows.Scan(
×
1128
                        &i.GraphChannel.ID,
×
1129
                        &i.GraphChannel.Version,
×
1130
                        &i.GraphChannel.Scid,
×
1131
                        &i.GraphChannel.NodeID1,
×
1132
                        &i.GraphChannel.NodeID2,
×
1133
                        &i.GraphChannel.Outpoint,
×
1134
                        &i.GraphChannel.Capacity,
×
1135
                        &i.GraphChannel.BitcoinKey1,
×
1136
                        &i.GraphChannel.BitcoinKey2,
×
1137
                        &i.GraphChannel.Node1Signature,
×
1138
                        &i.GraphChannel.Node2Signature,
×
1139
                        &i.GraphChannel.Bitcoin1Signature,
×
1140
                        &i.GraphChannel.Bitcoin2Signature,
×
1141
                        &i.Node1PubKey,
×
1142
                        &i.Node2PubKey,
×
1143
                ); err != nil {
×
1144
                        return nil, err
×
1145
                }
×
1146
                items = append(items, i)
×
1147
        }
1148
        if err := rows.Close(); err != nil {
×
1149
                return nil, err
×
1150
        }
×
1151
        if err := rows.Err(); err != nil {
×
1152
                return nil, err
×
1153
        }
×
1154
        return items, nil
×
1155
}
1156

1157
const getChannelsBySCIDWithPolicies = `-- name: GetChannelsBySCIDWithPolicies :many
1158
SELECT
1159
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
1160
    n1.id, n1.version, n1.pub_key, n1.alias, n1.last_update, n1.color, n1.signature,
1161
    n2.id, n2.version, n2.pub_key, n2.alias, n2.last_update, n2.color, n2.signature,
1162

1163
    -- Policy 1
1164
    cp1.id AS policy1_id,
1165
    cp1.node_id AS policy1_node_id,
1166
    cp1.version AS policy1_version,
1167
    cp1.timelock AS policy1_timelock,
1168
    cp1.fee_ppm AS policy1_fee_ppm,
1169
    cp1.base_fee_msat AS policy1_base_fee_msat,
1170
    cp1.min_htlc_msat AS policy1_min_htlc_msat,
1171
    cp1.max_htlc_msat AS policy1_max_htlc_msat,
1172
    cp1.last_update AS policy1_last_update,
1173
    cp1.disabled AS policy1_disabled,
1174
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
1175
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
1176
    cp1.message_flags AS policy1_message_flags,
1177
    cp1.channel_flags AS policy1_channel_flags,
1178
    cp1.signature AS policy1_signature,
1179

1180
    -- Policy 2
1181
    cp2.id AS policy2_id,
1182
    cp2.node_id AS policy2_node_id,
1183
    cp2.version AS policy2_version,
1184
    cp2.timelock AS policy2_timelock,
1185
    cp2.fee_ppm AS policy2_fee_ppm,
1186
    cp2.base_fee_msat AS policy2_base_fee_msat,
1187
    cp2.min_htlc_msat AS policy2_min_htlc_msat,
1188
    cp2.max_htlc_msat AS policy2_max_htlc_msat,
1189
    cp2.last_update AS policy2_last_update,
1190
    cp2.disabled AS policy2_disabled,
1191
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
1192
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
1193
    cp2.message_flags AS policy_2_message_flags,
1194
    cp2.channel_flags AS policy_2_channel_flags,
1195
    cp2.signature AS policy2_signature
1196

1197
FROM graph_channels c
1198
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
1199
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
1200
    LEFT JOIN graph_channel_policies cp1
1201
        ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
1202
    LEFT JOIN graph_channel_policies cp2
1203
        ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
1204
WHERE
1205
    c.version = $1
1206
  AND c.scid IN (/*SLICE:scids*/?)
1207
`
1208

1209
type GetChannelsBySCIDWithPoliciesParams struct {
1210
        Version int16
1211
        Scids   [][]byte
1212
}
1213

1214
type GetChannelsBySCIDWithPoliciesRow struct {
1215
        GraphChannel                   GraphChannel
1216
        GraphNode                      GraphNode
1217
        GraphNode_2                    GraphNode
1218
        Policy1ID                      sql.NullInt64
1219
        Policy1NodeID                  sql.NullInt64
1220
        Policy1Version                 sql.NullInt16
1221
        Policy1Timelock                sql.NullInt32
1222
        Policy1FeePpm                  sql.NullInt64
1223
        Policy1BaseFeeMsat             sql.NullInt64
1224
        Policy1MinHtlcMsat             sql.NullInt64
1225
        Policy1MaxHtlcMsat             sql.NullInt64
1226
        Policy1LastUpdate              sql.NullInt64
1227
        Policy1Disabled                sql.NullBool
1228
        Policy1InboundBaseFeeMsat      sql.NullInt64
1229
        Policy1InboundFeeRateMilliMsat sql.NullInt64
1230
        Policy1MessageFlags            sql.NullInt16
1231
        Policy1ChannelFlags            sql.NullInt16
1232
        Policy1Signature               []byte
1233
        Policy2ID                      sql.NullInt64
1234
        Policy2NodeID                  sql.NullInt64
1235
        Policy2Version                 sql.NullInt16
1236
        Policy2Timelock                sql.NullInt32
1237
        Policy2FeePpm                  sql.NullInt64
1238
        Policy2BaseFeeMsat             sql.NullInt64
1239
        Policy2MinHtlcMsat             sql.NullInt64
1240
        Policy2MaxHtlcMsat             sql.NullInt64
1241
        Policy2LastUpdate              sql.NullInt64
1242
        Policy2Disabled                sql.NullBool
1243
        Policy2InboundBaseFeeMsat      sql.NullInt64
1244
        Policy2InboundFeeRateMilliMsat sql.NullInt64
1245
        Policy2MessageFlags            sql.NullInt16
1246
        Policy2ChannelFlags            sql.NullInt16
1247
        Policy2Signature               []byte
1248
}
1249

NEW
1250
func (q *Queries) GetChannelsBySCIDWithPolicies(ctx context.Context, arg GetChannelsBySCIDWithPoliciesParams) ([]GetChannelsBySCIDWithPoliciesRow, error) {
×
NEW
1251
        query := getChannelsBySCIDWithPolicies
×
NEW
1252
        var queryParams []interface{}
×
NEW
1253
        queryParams = append(queryParams, arg.Version)
×
NEW
1254
        if len(arg.Scids) > 0 {
×
NEW
1255
                for _, v := range arg.Scids {
×
NEW
1256
                        queryParams = append(queryParams, v)
×
NEW
1257
                }
×
NEW
1258
                query = strings.Replace(query, "/*SLICE:scids*/?", makeQueryParams(len(queryParams), len(arg.Scids)), 1)
×
NEW
1259
        } else {
×
NEW
1260
                query = strings.Replace(query, "/*SLICE:scids*/?", "NULL", 1)
×
NEW
1261
        }
×
NEW
1262
        rows, err := q.db.QueryContext(ctx, query, queryParams...)
×
NEW
1263
        if err != nil {
×
NEW
1264
                return nil, err
×
NEW
1265
        }
×
NEW
1266
        defer rows.Close()
×
NEW
1267
        var items []GetChannelsBySCIDWithPoliciesRow
×
NEW
1268
        for rows.Next() {
×
NEW
1269
                var i GetChannelsBySCIDWithPoliciesRow
×
NEW
1270
                if err := rows.Scan(
×
NEW
1271
                        &i.GraphChannel.ID,
×
NEW
1272
                        &i.GraphChannel.Version,
×
NEW
1273
                        &i.GraphChannel.Scid,
×
NEW
1274
                        &i.GraphChannel.NodeID1,
×
NEW
1275
                        &i.GraphChannel.NodeID2,
×
NEW
1276
                        &i.GraphChannel.Outpoint,
×
NEW
1277
                        &i.GraphChannel.Capacity,
×
NEW
1278
                        &i.GraphChannel.BitcoinKey1,
×
NEW
1279
                        &i.GraphChannel.BitcoinKey2,
×
NEW
1280
                        &i.GraphChannel.Node1Signature,
×
NEW
1281
                        &i.GraphChannel.Node2Signature,
×
NEW
1282
                        &i.GraphChannel.Bitcoin1Signature,
×
NEW
1283
                        &i.GraphChannel.Bitcoin2Signature,
×
NEW
1284
                        &i.GraphNode.ID,
×
NEW
1285
                        &i.GraphNode.Version,
×
NEW
1286
                        &i.GraphNode.PubKey,
×
NEW
1287
                        &i.GraphNode.Alias,
×
NEW
1288
                        &i.GraphNode.LastUpdate,
×
NEW
1289
                        &i.GraphNode.Color,
×
NEW
1290
                        &i.GraphNode.Signature,
×
NEW
1291
                        &i.GraphNode_2.ID,
×
NEW
1292
                        &i.GraphNode_2.Version,
×
NEW
1293
                        &i.GraphNode_2.PubKey,
×
NEW
1294
                        &i.GraphNode_2.Alias,
×
NEW
1295
                        &i.GraphNode_2.LastUpdate,
×
NEW
1296
                        &i.GraphNode_2.Color,
×
NEW
1297
                        &i.GraphNode_2.Signature,
×
NEW
1298
                        &i.Policy1ID,
×
NEW
1299
                        &i.Policy1NodeID,
×
NEW
1300
                        &i.Policy1Version,
×
NEW
1301
                        &i.Policy1Timelock,
×
NEW
1302
                        &i.Policy1FeePpm,
×
NEW
1303
                        &i.Policy1BaseFeeMsat,
×
NEW
1304
                        &i.Policy1MinHtlcMsat,
×
NEW
1305
                        &i.Policy1MaxHtlcMsat,
×
NEW
1306
                        &i.Policy1LastUpdate,
×
NEW
1307
                        &i.Policy1Disabled,
×
NEW
1308
                        &i.Policy1InboundBaseFeeMsat,
×
NEW
1309
                        &i.Policy1InboundFeeRateMilliMsat,
×
NEW
1310
                        &i.Policy1MessageFlags,
×
NEW
1311
                        &i.Policy1ChannelFlags,
×
NEW
1312
                        &i.Policy1Signature,
×
NEW
1313
                        &i.Policy2ID,
×
NEW
1314
                        &i.Policy2NodeID,
×
NEW
1315
                        &i.Policy2Version,
×
NEW
1316
                        &i.Policy2Timelock,
×
NEW
1317
                        &i.Policy2FeePpm,
×
NEW
1318
                        &i.Policy2BaseFeeMsat,
×
NEW
1319
                        &i.Policy2MinHtlcMsat,
×
NEW
1320
                        &i.Policy2MaxHtlcMsat,
×
NEW
1321
                        &i.Policy2LastUpdate,
×
NEW
1322
                        &i.Policy2Disabled,
×
NEW
1323
                        &i.Policy2InboundBaseFeeMsat,
×
NEW
1324
                        &i.Policy2InboundFeeRateMilliMsat,
×
NEW
1325
                        &i.Policy2MessageFlags,
×
NEW
1326
                        &i.Policy2ChannelFlags,
×
NEW
1327
                        &i.Policy2Signature,
×
NEW
1328
                ); err != nil {
×
NEW
1329
                        return nil, err
×
NEW
1330
                }
×
NEW
1331
                items = append(items, i)
×
1332
        }
NEW
1333
        if err := rows.Close(); err != nil {
×
NEW
1334
                return nil, err
×
NEW
1335
        }
×
NEW
1336
        if err := rows.Err(); err != nil {
×
NEW
1337
                return nil, err
×
NEW
1338
        }
×
NEW
1339
        return items, nil
×
1340
}
1341

1342
const getChannelsBySCIDs = `-- name: GetChannelsBySCIDs :many
1343
SELECT id, version, scid, node_id_1, node_id_2, outpoint, capacity, bitcoin_key_1, bitcoin_key_2, node_1_signature, node_2_signature, bitcoin_1_signature, bitcoin_2_signature FROM graph_channels
1344
WHERE version = $1
1345
  AND scid IN (/*SLICE:scids*/?)
1346
`
1347

1348
type GetChannelsBySCIDsParams struct {
1349
        Version int16
1350
        Scids   [][]byte
1351
}
1352

NEW
1353
func (q *Queries) GetChannelsBySCIDs(ctx context.Context, arg GetChannelsBySCIDsParams) ([]GraphChannel, error) {
×
NEW
1354
        query := getChannelsBySCIDs
×
NEW
1355
        var queryParams []interface{}
×
NEW
1356
        queryParams = append(queryParams, arg.Version)
×
NEW
1357
        if len(arg.Scids) > 0 {
×
NEW
1358
                for _, v := range arg.Scids {
×
NEW
1359
                        queryParams = append(queryParams, v)
×
NEW
1360
                }
×
NEW
1361
                query = strings.Replace(query, "/*SLICE:scids*/?", makeQueryParams(len(queryParams), len(arg.Scids)), 1)
×
NEW
1362
        } else {
×
NEW
1363
                query = strings.Replace(query, "/*SLICE:scids*/?", "NULL", 1)
×
NEW
1364
        }
×
NEW
1365
        rows, err := q.db.QueryContext(ctx, query, queryParams...)
×
NEW
1366
        if err != nil {
×
NEW
1367
                return nil, err
×
NEW
1368
        }
×
NEW
1369
        defer rows.Close()
×
NEW
1370
        var items []GraphChannel
×
NEW
1371
        for rows.Next() {
×
NEW
1372
                var i GraphChannel
×
NEW
1373
                if err := rows.Scan(
×
NEW
1374
                        &i.ID,
×
NEW
1375
                        &i.Version,
×
NEW
1376
                        &i.Scid,
×
NEW
1377
                        &i.NodeID1,
×
NEW
1378
                        &i.NodeID2,
×
NEW
1379
                        &i.Outpoint,
×
NEW
1380
                        &i.Capacity,
×
NEW
1381
                        &i.BitcoinKey1,
×
NEW
1382
                        &i.BitcoinKey2,
×
NEW
1383
                        &i.Node1Signature,
×
NEW
1384
                        &i.Node2Signature,
×
NEW
1385
                        &i.Bitcoin1Signature,
×
NEW
1386
                        &i.Bitcoin2Signature,
×
NEW
1387
                ); err != nil {
×
NEW
1388
                        return nil, err
×
NEW
1389
                }
×
NEW
1390
                items = append(items, i)
×
1391
        }
NEW
1392
        if err := rows.Close(); err != nil {
×
NEW
1393
                return nil, err
×
NEW
1394
        }
×
NEW
1395
        if err := rows.Err(); err != nil {
×
NEW
1396
                return nil, err
×
NEW
1397
        }
×
NEW
1398
        return items, nil
×
1399
}
1400

1401
const getExtraNodeTypes = `-- name: GetExtraNodeTypes :many
1402
SELECT node_id, type, value
1403
FROM graph_node_extra_types
1404
WHERE node_id = $1
1405
`
1406

1407
func (q *Queries) GetExtraNodeTypes(ctx context.Context, nodeID int64) ([]GraphNodeExtraType, error) {
×
1408
        rows, err := q.db.QueryContext(ctx, getExtraNodeTypes, nodeID)
×
1409
        if err != nil {
×
1410
                return nil, err
×
1411
        }
×
1412
        defer rows.Close()
×
1413
        var items []GraphNodeExtraType
×
1414
        for rows.Next() {
×
1415
                var i GraphNodeExtraType
×
1416
                if err := rows.Scan(&i.NodeID, &i.Type, &i.Value); err != nil {
×
1417
                        return nil, err
×
1418
                }
×
1419
                items = append(items, i)
×
1420
        }
1421
        if err := rows.Close(); err != nil {
×
1422
                return nil, err
×
1423
        }
×
1424
        if err := rows.Err(); err != nil {
×
1425
                return nil, err
×
1426
        }
×
1427
        return items, nil
×
1428
}
1429

1430
const getNodeAddressesByPubKey = `-- name: GetNodeAddressesByPubKey :many
1431
SELECT a.type, a.address
1432
FROM graph_nodes n
1433
LEFT JOIN graph_node_addresses a ON a.node_id = n.id
1434
WHERE n.pub_key = $1 AND n.version = $2
1435
ORDER BY a.type ASC, a.position ASC
1436
`
1437

1438
type GetNodeAddressesByPubKeyParams struct {
1439
        PubKey  []byte
1440
        Version int16
1441
}
1442

1443
type GetNodeAddressesByPubKeyRow struct {
1444
        Type    sql.NullInt16
1445
        Address sql.NullString
1446
}
1447

1448
func (q *Queries) GetNodeAddressesByPubKey(ctx context.Context, arg GetNodeAddressesByPubKeyParams) ([]GetNodeAddressesByPubKeyRow, error) {
×
1449
        rows, err := q.db.QueryContext(ctx, getNodeAddressesByPubKey, arg.PubKey, arg.Version)
×
1450
        if err != nil {
×
1451
                return nil, err
×
1452
        }
×
1453
        defer rows.Close()
×
1454
        var items []GetNodeAddressesByPubKeyRow
×
1455
        for rows.Next() {
×
1456
                var i GetNodeAddressesByPubKeyRow
×
1457
                if err := rows.Scan(&i.Type, &i.Address); err != nil {
×
1458
                        return nil, err
×
1459
                }
×
1460
                items = append(items, i)
×
1461
        }
1462
        if err := rows.Close(); err != nil {
×
1463
                return nil, err
×
1464
        }
×
1465
        if err := rows.Err(); err != nil {
×
1466
                return nil, err
×
1467
        }
×
1468
        return items, nil
×
1469
}
1470

1471
const getNodeByPubKey = `-- name: GetNodeByPubKey :one
1472
SELECT id, version, pub_key, alias, last_update, color, signature
1473
FROM graph_nodes
1474
WHERE pub_key = $1
1475
  AND version = $2
1476
`
1477

1478
type GetNodeByPubKeyParams struct {
1479
        PubKey  []byte
1480
        Version int16
1481
}
1482

1483
func (q *Queries) GetNodeByPubKey(ctx context.Context, arg GetNodeByPubKeyParams) (GraphNode, error) {
×
1484
        row := q.db.QueryRowContext(ctx, getNodeByPubKey, arg.PubKey, arg.Version)
×
1485
        var i GraphNode
×
1486
        err := row.Scan(
×
1487
                &i.ID,
×
1488
                &i.Version,
×
1489
                &i.PubKey,
×
1490
                &i.Alias,
×
1491
                &i.LastUpdate,
×
1492
                &i.Color,
×
1493
                &i.Signature,
×
1494
        )
×
1495
        return i, err
×
1496
}
×
1497

1498
const getNodeFeatures = `-- name: GetNodeFeatures :many
1499
SELECT node_id, feature_bit
1500
FROM graph_node_features
1501
WHERE node_id = $1
1502
`
1503

1504
func (q *Queries) GetNodeFeatures(ctx context.Context, nodeID int64) ([]GraphNodeFeature, error) {
×
1505
        rows, err := q.db.QueryContext(ctx, getNodeFeatures, nodeID)
×
1506
        if err != nil {
×
1507
                return nil, err
×
1508
        }
×
1509
        defer rows.Close()
×
1510
        var items []GraphNodeFeature
×
1511
        for rows.Next() {
×
1512
                var i GraphNodeFeature
×
1513
                if err := rows.Scan(&i.NodeID, &i.FeatureBit); err != nil {
×
1514
                        return nil, err
×
1515
                }
×
1516
                items = append(items, i)
×
1517
        }
1518
        if err := rows.Close(); err != nil {
×
1519
                return nil, err
×
1520
        }
×
1521
        if err := rows.Err(); err != nil {
×
1522
                return nil, err
×
1523
        }
×
1524
        return items, nil
×
1525
}
1526

1527
const getNodeFeaturesByPubKey = `-- name: GetNodeFeaturesByPubKey :many
1528
SELECT f.feature_bit
1529
FROM graph_nodes n
1530
    JOIN graph_node_features f ON f.node_id = n.id
1531
WHERE n.pub_key = $1
1532
  AND n.version = $2
1533
`
1534

1535
type GetNodeFeaturesByPubKeyParams struct {
1536
        PubKey  []byte
1537
        Version int16
1538
}
1539

1540
func (q *Queries) GetNodeFeaturesByPubKey(ctx context.Context, arg GetNodeFeaturesByPubKeyParams) ([]int32, error) {
×
1541
        rows, err := q.db.QueryContext(ctx, getNodeFeaturesByPubKey, arg.PubKey, arg.Version)
×
1542
        if err != nil {
×
1543
                return nil, err
×
1544
        }
×
1545
        defer rows.Close()
×
1546
        var items []int32
×
1547
        for rows.Next() {
×
1548
                var feature_bit int32
×
1549
                if err := rows.Scan(&feature_bit); err != nil {
×
1550
                        return nil, err
×
1551
                }
×
1552
                items = append(items, feature_bit)
×
1553
        }
1554
        if err := rows.Close(); err != nil {
×
1555
                return nil, err
×
1556
        }
×
1557
        if err := rows.Err(); err != nil {
×
1558
                return nil, err
×
1559
        }
×
1560
        return items, nil
×
1561
}
1562

1563
const getNodeIDByPubKey = `-- name: GetNodeIDByPubKey :one
1564
SELECT id
1565
FROM graph_nodes
1566
WHERE pub_key = $1
1567
  AND version = $2
1568
`
1569

1570
type GetNodeIDByPubKeyParams struct {
1571
        PubKey  []byte
1572
        Version int16
1573
}
1574

1575
func (q *Queries) GetNodeIDByPubKey(ctx context.Context, arg GetNodeIDByPubKeyParams) (int64, error) {
×
1576
        row := q.db.QueryRowContext(ctx, getNodeIDByPubKey, arg.PubKey, arg.Version)
×
1577
        var id int64
×
1578
        err := row.Scan(&id)
×
1579
        return id, err
×
1580
}
×
1581

1582
const getNodesByLastUpdateRange = `-- name: GetNodesByLastUpdateRange :many
1583
SELECT id, version, pub_key, alias, last_update, color, signature
1584
FROM graph_nodes
1585
WHERE last_update >= $1
1586
  AND last_update < $2
1587
`
1588

1589
type GetNodesByLastUpdateRangeParams struct {
1590
        StartTime sql.NullInt64
1591
        EndTime   sql.NullInt64
1592
}
1593

1594
func (q *Queries) GetNodesByLastUpdateRange(ctx context.Context, arg GetNodesByLastUpdateRangeParams) ([]GraphNode, error) {
×
1595
        rows, err := q.db.QueryContext(ctx, getNodesByLastUpdateRange, arg.StartTime, arg.EndTime)
×
1596
        if err != nil {
×
1597
                return nil, err
×
1598
        }
×
1599
        defer rows.Close()
×
1600
        var items []GraphNode
×
1601
        for rows.Next() {
×
1602
                var i GraphNode
×
1603
                if err := rows.Scan(
×
1604
                        &i.ID,
×
1605
                        &i.Version,
×
1606
                        &i.PubKey,
×
1607
                        &i.Alias,
×
1608
                        &i.LastUpdate,
×
1609
                        &i.Color,
×
1610
                        &i.Signature,
×
1611
                ); err != nil {
×
1612
                        return nil, err
×
1613
                }
×
1614
                items = append(items, i)
×
1615
        }
1616
        if err := rows.Close(); err != nil {
×
1617
                return nil, err
×
1618
        }
×
1619
        if err := rows.Err(); err != nil {
×
1620
                return nil, err
×
1621
        }
×
1622
        return items, nil
×
1623
}
1624

1625
const getPruneHashByHeight = `-- name: GetPruneHashByHeight :one
1626
SELECT block_hash
1627
FROM graph_prune_log
1628
WHERE block_height = $1
1629
`
1630

1631
func (q *Queries) GetPruneHashByHeight(ctx context.Context, blockHeight int64) ([]byte, error) {
×
1632
        row := q.db.QueryRowContext(ctx, getPruneHashByHeight, blockHeight)
×
1633
        var block_hash []byte
×
1634
        err := row.Scan(&block_hash)
×
1635
        return block_hash, err
×
1636
}
×
1637

1638
const getPruneTip = `-- name: GetPruneTip :one
1639
SELECT block_height, block_hash
1640
FROM graph_prune_log
1641
ORDER BY block_height DESC
1642
LIMIT 1
1643
`
1644

1645
func (q *Queries) GetPruneTip(ctx context.Context) (GraphPruneLog, error) {
×
1646
        row := q.db.QueryRowContext(ctx, getPruneTip)
×
1647
        var i GraphPruneLog
×
1648
        err := row.Scan(&i.BlockHeight, &i.BlockHash)
×
1649
        return i, err
×
1650
}
×
1651

1652
const getPublicV1ChannelsBySCID = `-- name: GetPublicV1ChannelsBySCID :many
1653
SELECT id, version, scid, node_id_1, node_id_2, outpoint, capacity, bitcoin_key_1, bitcoin_key_2, node_1_signature, node_2_signature, bitcoin_1_signature, bitcoin_2_signature
1654
FROM graph_channels
1655
WHERE node_1_signature IS NOT NULL
1656
  AND scid >= $1
1657
  AND scid < $2
1658
`
1659

1660
type GetPublicV1ChannelsBySCIDParams struct {
1661
        StartScid []byte
1662
        EndScid   []byte
1663
}
1664

1665
func (q *Queries) GetPublicV1ChannelsBySCID(ctx context.Context, arg GetPublicV1ChannelsBySCIDParams) ([]GraphChannel, error) {
×
1666
        rows, err := q.db.QueryContext(ctx, getPublicV1ChannelsBySCID, arg.StartScid, arg.EndScid)
×
1667
        if err != nil {
×
1668
                return nil, err
×
1669
        }
×
1670
        defer rows.Close()
×
1671
        var items []GraphChannel
×
1672
        for rows.Next() {
×
1673
                var i GraphChannel
×
1674
                if err := rows.Scan(
×
1675
                        &i.ID,
×
1676
                        &i.Version,
×
1677
                        &i.Scid,
×
1678
                        &i.NodeID1,
×
1679
                        &i.NodeID2,
×
1680
                        &i.Outpoint,
×
1681
                        &i.Capacity,
×
1682
                        &i.BitcoinKey1,
×
1683
                        &i.BitcoinKey2,
×
1684
                        &i.Node1Signature,
×
1685
                        &i.Node2Signature,
×
1686
                        &i.Bitcoin1Signature,
×
1687
                        &i.Bitcoin2Signature,
×
1688
                ); err != nil {
×
1689
                        return nil, err
×
1690
                }
×
1691
                items = append(items, i)
×
1692
        }
1693
        if err := rows.Close(); err != nil {
×
1694
                return nil, err
×
1695
        }
×
1696
        if err := rows.Err(); err != nil {
×
1697
                return nil, err
×
1698
        }
×
1699
        return items, nil
×
1700
}
1701

1702
const getSCIDByOutpoint = `-- name: GetSCIDByOutpoint :one
1703
SELECT scid from graph_channels
1704
WHERE outpoint = $1 AND version = $2
1705
`
1706

1707
type GetSCIDByOutpointParams struct {
1708
        Outpoint string
1709
        Version  int16
1710
}
1711

1712
func (q *Queries) GetSCIDByOutpoint(ctx context.Context, arg GetSCIDByOutpointParams) ([]byte, error) {
×
1713
        row := q.db.QueryRowContext(ctx, getSCIDByOutpoint, arg.Outpoint, arg.Version)
×
1714
        var scid []byte
×
1715
        err := row.Scan(&scid)
×
1716
        return scid, err
×
1717
}
×
1718

1719
const getSourceNodesByVersion = `-- name: GetSourceNodesByVersion :many
1720
SELECT sn.node_id, n.pub_key
1721
FROM graph_source_nodes sn
1722
    JOIN graph_nodes n ON sn.node_id = n.id
1723
WHERE n.version = $1
1724
`
1725

1726
type GetSourceNodesByVersionRow struct {
1727
        NodeID int64
1728
        PubKey []byte
1729
}
1730

1731
func (q *Queries) GetSourceNodesByVersion(ctx context.Context, version int16) ([]GetSourceNodesByVersionRow, error) {
×
1732
        rows, err := q.db.QueryContext(ctx, getSourceNodesByVersion, version)
×
1733
        if err != nil {
×
1734
                return nil, err
×
1735
        }
×
1736
        defer rows.Close()
×
1737
        var items []GetSourceNodesByVersionRow
×
1738
        for rows.Next() {
×
1739
                var i GetSourceNodesByVersionRow
×
1740
                if err := rows.Scan(&i.NodeID, &i.PubKey); err != nil {
×
1741
                        return nil, err
×
1742
                }
×
1743
                items = append(items, i)
×
1744
        }
1745
        if err := rows.Close(); err != nil {
×
1746
                return nil, err
×
1747
        }
×
1748
        if err := rows.Err(); err != nil {
×
1749
                return nil, err
×
1750
        }
×
1751
        return items, nil
×
1752
}
1753

1754
const getV1DisabledSCIDs = `-- name: GetV1DisabledSCIDs :many
1755
SELECT c.scid
1756
FROM graph_channels c
1757
    JOIN graph_channel_policies cp ON cp.channel_id = c.id
1758
WHERE cp.disabled = true
1759
AND c.version = 1
1760
GROUP BY c.scid
1761
HAVING COUNT(*) > 1
1762
`
1763

1764
// NOTE: this is V1 specific since for V1, disabled is a
1765
// simple, single boolean. The proposed V2 policy
1766
// structure will have a more complex disabled bit vector
1767
// and so the query for V2 may differ.
1768
func (q *Queries) GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error) {
×
1769
        rows, err := q.db.QueryContext(ctx, getV1DisabledSCIDs)
×
1770
        if err != nil {
×
1771
                return nil, err
×
1772
        }
×
1773
        defer rows.Close()
×
1774
        var items [][]byte
×
1775
        for rows.Next() {
×
1776
                var scid []byte
×
1777
                if err := rows.Scan(&scid); err != nil {
×
1778
                        return nil, err
×
1779
                }
×
1780
                items = append(items, scid)
×
1781
        }
1782
        if err := rows.Close(); err != nil {
×
1783
                return nil, err
×
1784
        }
×
1785
        if err := rows.Err(); err != nil {
×
1786
                return nil, err
×
1787
        }
×
1788
        return items, nil
×
1789
}
1790

1791
const getZombieChannel = `-- name: GetZombieChannel :one
1792
SELECT scid, version, node_key_1, node_key_2
1793
FROM graph_zombie_channels
1794
WHERE scid = $1
1795
AND version = $2
1796
`
1797

1798
type GetZombieChannelParams struct {
1799
        Scid    []byte
1800
        Version int16
1801
}
1802

1803
func (q *Queries) GetZombieChannel(ctx context.Context, arg GetZombieChannelParams) (GraphZombieChannel, error) {
×
1804
        row := q.db.QueryRowContext(ctx, getZombieChannel, arg.Scid, arg.Version)
×
1805
        var i GraphZombieChannel
×
1806
        err := row.Scan(
×
1807
                &i.Scid,
×
1808
                &i.Version,
×
1809
                &i.NodeKey1,
×
1810
                &i.NodeKey2,
×
1811
        )
×
1812
        return i, err
×
1813
}
×
1814

1815
const highestSCID = `-- name: HighestSCID :one
1816
SELECT scid
1817
FROM graph_channels
1818
WHERE version = $1
1819
ORDER BY scid DESC
1820
LIMIT 1
1821
`
1822

1823
func (q *Queries) HighestSCID(ctx context.Context, version int16) ([]byte, error) {
×
1824
        row := q.db.QueryRowContext(ctx, highestSCID, version)
×
1825
        var scid []byte
×
1826
        err := row.Scan(&scid)
×
1827
        return scid, err
×
1828
}
×
1829

1830
const insertChanPolicyExtraType = `-- name: InsertChanPolicyExtraType :exec
1831
/* ─────────────────────────────────────────────
1832
   graph_channel_policy_extra_types table queries
1833
   ─────────────────────────────────────────────
1834
*/
1835

1836
INSERT INTO graph_channel_policy_extra_types (
1837
    channel_policy_id, type, value
1838
)
1839
VALUES ($1, $2, $3)
1840
`
1841

1842
type InsertChanPolicyExtraTypeParams struct {
1843
        ChannelPolicyID int64
1844
        Type            int64
1845
        Value           []byte
1846
}
1847

1848
func (q *Queries) InsertChanPolicyExtraType(ctx context.Context, arg InsertChanPolicyExtraTypeParams) error {
×
1849
        _, err := q.db.ExecContext(ctx, insertChanPolicyExtraType, arg.ChannelPolicyID, arg.Type, arg.Value)
×
1850
        return err
×
1851
}
×
1852

1853
const insertChannelFeature = `-- name: InsertChannelFeature :exec
1854
/* ─────────────────────────────────────────────
1855
   graph_channel_features table queries
1856
   ─────────────────────────────────────────────
1857
*/
1858

1859
INSERT INTO graph_channel_features (
1860
    channel_id, feature_bit
1861
) VALUES (
1862
    $1, $2
1863
)
1864
`
1865

1866
type InsertChannelFeatureParams struct {
1867
        ChannelID  int64
1868
        FeatureBit int32
1869
}
1870

1871
func (q *Queries) InsertChannelFeature(ctx context.Context, arg InsertChannelFeatureParams) error {
×
1872
        _, err := q.db.ExecContext(ctx, insertChannelFeature, arg.ChannelID, arg.FeatureBit)
×
1873
        return err
×
1874
}
×
1875

1876
const insertClosedChannel = `-- name: InsertClosedChannel :exec
1877
/* ─────────────────────────────────────────────
1878
   graph_closed_scid table queries
1879
   ────────────────────────────────────────────-
1880
*/
1881

1882
INSERT INTO graph_closed_scids (scid)
1883
VALUES ($1)
1884
ON CONFLICT (scid) DO NOTHING
1885
`
1886

1887
func (q *Queries) InsertClosedChannel(ctx context.Context, scid []byte) error {
×
1888
        _, err := q.db.ExecContext(ctx, insertClosedChannel, scid)
×
1889
        return err
×
1890
}
×
1891

1892
const insertNodeAddress = `-- name: InsertNodeAddress :exec
1893
/* ─────────────────────────────────────────────
1894
   graph_node_addresses table queries
1895
   ───────────────────────────────────��─────────
1896
*/
1897

1898
INSERT INTO graph_node_addresses (
1899
    node_id,
1900
    type,
1901
    address,
1902
    position
1903
) VALUES (
1904
    $1, $2, $3, $4
1905
 )
1906
`
1907

1908
type InsertNodeAddressParams struct {
1909
        NodeID   int64
1910
        Type     int16
1911
        Address  string
1912
        Position int32
1913
}
1914

1915
func (q *Queries) InsertNodeAddress(ctx context.Context, arg InsertNodeAddressParams) error {
×
1916
        _, err := q.db.ExecContext(ctx, insertNodeAddress,
×
1917
                arg.NodeID,
×
1918
                arg.Type,
×
1919
                arg.Address,
×
1920
                arg.Position,
×
1921
        )
×
1922
        return err
×
1923
}
×
1924

1925
const insertNodeFeature = `-- name: InsertNodeFeature :exec
1926
/* ─────────────────────────────────────────────
1927
   graph_node_features table queries
1928
   ─────────────────────────────────────────────
1929
*/
1930

1931
INSERT INTO graph_node_features (
1932
    node_id, feature_bit
1933
) VALUES (
1934
    $1, $2
1935
)
1936
`
1937

1938
type InsertNodeFeatureParams struct {
1939
        NodeID     int64
1940
        FeatureBit int32
1941
}
1942

1943
func (q *Queries) InsertNodeFeature(ctx context.Context, arg InsertNodeFeatureParams) error {
×
1944
        _, err := q.db.ExecContext(ctx, insertNodeFeature, arg.NodeID, arg.FeatureBit)
×
1945
        return err
×
1946
}
×
1947

1948
const isClosedChannel = `-- name: IsClosedChannel :one
1949
SELECT EXISTS (
1950
    SELECT 1
1951
    FROM graph_closed_scids
1952
    WHERE scid = $1
1953
)
1954
`
1955

1956
func (q *Queries) IsClosedChannel(ctx context.Context, scid []byte) (bool, error) {
×
1957
        row := q.db.QueryRowContext(ctx, isClosedChannel, scid)
×
1958
        var exists bool
×
1959
        err := row.Scan(&exists)
×
1960
        return exists, err
×
1961
}
×
1962

1963
const isPublicV1Node = `-- name: IsPublicV1Node :one
1964
SELECT EXISTS (
1965
    SELECT 1
1966
    FROM graph_channels c
1967
    JOIN graph_nodes n ON n.id = c.node_id_1 OR n.id = c.node_id_2
1968
    -- NOTE: we hard-code the version here since the clauses
1969
    -- here that determine if a node is public is specific
1970
    -- to the V1 gossip protocol. In V1, a node is public
1971
    -- if it has a public channel and a public channel is one
1972
    -- where we have the set of signatures of the channel
1973
    -- announcement. It is enough to just check that we have
1974
    -- one of the signatures since we only ever set them
1975
    -- together.
1976
    WHERE c.version = 1
1977
      AND c.bitcoin_1_signature IS NOT NULL
1978
      AND n.pub_key = $1
1979
)
1980
`
1981

1982
func (q *Queries) IsPublicV1Node(ctx context.Context, pubKey []byte) (bool, error) {
×
1983
        row := q.db.QueryRowContext(ctx, isPublicV1Node, pubKey)
×
1984
        var exists bool
×
1985
        err := row.Scan(&exists)
×
1986
        return exists, err
×
1987
}
×
1988

1989
const isZombieChannel = `-- name: IsZombieChannel :one
1990
SELECT EXISTS (
1991
    SELECT 1
1992
    FROM graph_zombie_channels
1993
    WHERE scid = $1
1994
    AND version = $2
1995
) AS is_zombie
1996
`
1997

1998
type IsZombieChannelParams struct {
1999
        Scid    []byte
2000
        Version int16
2001
}
2002

2003
func (q *Queries) IsZombieChannel(ctx context.Context, arg IsZombieChannelParams) (bool, error) {
×
2004
        row := q.db.QueryRowContext(ctx, isZombieChannel, arg.Scid, arg.Version)
×
2005
        var is_zombie bool
×
2006
        err := row.Scan(&is_zombie)
×
2007
        return is_zombie, err
×
2008
}
×
2009

2010
const listChannelsByNodeID = `-- name: ListChannelsByNodeID :many
2011
SELECT c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
2012
    n1.pub_key AS node1_pubkey,
2013
    n2.pub_key AS node2_pubkey,
2014

2015
    -- Policy 1
2016
    -- TODO(elle): use sqlc.embed to embed policy structs
2017
    --  once this issue is resolved:
2018
    --  https://github.com/sqlc-dev/sqlc/issues/2997
2019
    cp1.id AS policy1_id,
2020
    cp1.node_id AS policy1_node_id,
2021
    cp1.version AS policy1_version,
2022
    cp1.timelock AS policy1_timelock,
2023
    cp1.fee_ppm AS policy1_fee_ppm,
2024
    cp1.base_fee_msat AS policy1_base_fee_msat,
2025
    cp1.min_htlc_msat AS policy1_min_htlc_msat,
2026
    cp1.max_htlc_msat AS policy1_max_htlc_msat,
2027
    cp1.last_update AS policy1_last_update,
2028
    cp1.disabled AS policy1_disabled,
2029
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
2030
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
2031
    cp1.message_flags AS policy1_message_flags,
2032
    cp1.channel_flags AS policy1_channel_flags,
2033
    cp1.signature AS policy1_signature,
2034

2035
       -- Policy 2
2036
    cp2.id AS policy2_id,
2037
    cp2.node_id AS policy2_node_id,
2038
    cp2.version AS policy2_version,
2039
    cp2.timelock AS policy2_timelock,
2040
    cp2.fee_ppm AS policy2_fee_ppm,
2041
    cp2.base_fee_msat AS policy2_base_fee_msat,
2042
    cp2.min_htlc_msat AS policy2_min_htlc_msat,
2043
    cp2.max_htlc_msat AS policy2_max_htlc_msat,
2044
    cp2.last_update AS policy2_last_update,
2045
    cp2.disabled AS policy2_disabled,
2046
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
2047
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
2048
    cp2.message_flags AS policy2_message_flags,
2049
    cp2.channel_flags AS policy2_channel_flags,
2050
    cp2.signature AS policy2_signature
2051

2052
FROM graph_channels c
2053
    JOIN graph_nodes n1 ON c.node_id_1 = n1.id
2054
    JOIN graph_nodes n2 ON c.node_id_2 = n2.id
2055
    LEFT JOIN graph_channel_policies cp1
2056
    ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
2057
    LEFT JOIN graph_channel_policies cp2
2058
    ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
2059
WHERE c.version = $1
2060
  AND (c.node_id_1 = $2 OR c.node_id_2 = $2)
2061
`
2062

2063
type ListChannelsByNodeIDParams struct {
2064
        Version int16
2065
        NodeID1 int64
2066
}
2067

2068
type ListChannelsByNodeIDRow struct {
2069
        GraphChannel                   GraphChannel
2070
        Node1Pubkey                    []byte
2071
        Node2Pubkey                    []byte
2072
        Policy1ID                      sql.NullInt64
2073
        Policy1NodeID                  sql.NullInt64
2074
        Policy1Version                 sql.NullInt16
2075
        Policy1Timelock                sql.NullInt32
2076
        Policy1FeePpm                  sql.NullInt64
2077
        Policy1BaseFeeMsat             sql.NullInt64
2078
        Policy1MinHtlcMsat             sql.NullInt64
2079
        Policy1MaxHtlcMsat             sql.NullInt64
2080
        Policy1LastUpdate              sql.NullInt64
2081
        Policy1Disabled                sql.NullBool
2082
        Policy1InboundBaseFeeMsat      sql.NullInt64
2083
        Policy1InboundFeeRateMilliMsat sql.NullInt64
2084
        Policy1MessageFlags            sql.NullInt16
2085
        Policy1ChannelFlags            sql.NullInt16
2086
        Policy1Signature               []byte
2087
        Policy2ID                      sql.NullInt64
2088
        Policy2NodeID                  sql.NullInt64
2089
        Policy2Version                 sql.NullInt16
2090
        Policy2Timelock                sql.NullInt32
2091
        Policy2FeePpm                  sql.NullInt64
2092
        Policy2BaseFeeMsat             sql.NullInt64
2093
        Policy2MinHtlcMsat             sql.NullInt64
2094
        Policy2MaxHtlcMsat             sql.NullInt64
2095
        Policy2LastUpdate              sql.NullInt64
2096
        Policy2Disabled                sql.NullBool
2097
        Policy2InboundBaseFeeMsat      sql.NullInt64
2098
        Policy2InboundFeeRateMilliMsat sql.NullInt64
2099
        Policy2MessageFlags            sql.NullInt16
2100
        Policy2ChannelFlags            sql.NullInt16
2101
        Policy2Signature               []byte
2102
}
2103

2104
func (q *Queries) ListChannelsByNodeID(ctx context.Context, arg ListChannelsByNodeIDParams) ([]ListChannelsByNodeIDRow, error) {
×
2105
        rows, err := q.db.QueryContext(ctx, listChannelsByNodeID, arg.Version, arg.NodeID1)
×
2106
        if err != nil {
×
2107
                return nil, err
×
2108
        }
×
2109
        defer rows.Close()
×
2110
        var items []ListChannelsByNodeIDRow
×
2111
        for rows.Next() {
×
2112
                var i ListChannelsByNodeIDRow
×
2113
                if err := rows.Scan(
×
2114
                        &i.GraphChannel.ID,
×
2115
                        &i.GraphChannel.Version,
×
2116
                        &i.GraphChannel.Scid,
×
2117
                        &i.GraphChannel.NodeID1,
×
2118
                        &i.GraphChannel.NodeID2,
×
2119
                        &i.GraphChannel.Outpoint,
×
2120
                        &i.GraphChannel.Capacity,
×
2121
                        &i.GraphChannel.BitcoinKey1,
×
2122
                        &i.GraphChannel.BitcoinKey2,
×
2123
                        &i.GraphChannel.Node1Signature,
×
2124
                        &i.GraphChannel.Node2Signature,
×
2125
                        &i.GraphChannel.Bitcoin1Signature,
×
2126
                        &i.GraphChannel.Bitcoin2Signature,
×
2127
                        &i.Node1Pubkey,
×
2128
                        &i.Node2Pubkey,
×
2129
                        &i.Policy1ID,
×
2130
                        &i.Policy1NodeID,
×
2131
                        &i.Policy1Version,
×
2132
                        &i.Policy1Timelock,
×
2133
                        &i.Policy1FeePpm,
×
2134
                        &i.Policy1BaseFeeMsat,
×
2135
                        &i.Policy1MinHtlcMsat,
×
2136
                        &i.Policy1MaxHtlcMsat,
×
2137
                        &i.Policy1LastUpdate,
×
2138
                        &i.Policy1Disabled,
×
2139
                        &i.Policy1InboundBaseFeeMsat,
×
2140
                        &i.Policy1InboundFeeRateMilliMsat,
×
2141
                        &i.Policy1MessageFlags,
×
2142
                        &i.Policy1ChannelFlags,
×
2143
                        &i.Policy1Signature,
×
2144
                        &i.Policy2ID,
×
2145
                        &i.Policy2NodeID,
×
2146
                        &i.Policy2Version,
×
2147
                        &i.Policy2Timelock,
×
2148
                        &i.Policy2FeePpm,
×
2149
                        &i.Policy2BaseFeeMsat,
×
2150
                        &i.Policy2MinHtlcMsat,
×
2151
                        &i.Policy2MaxHtlcMsat,
×
2152
                        &i.Policy2LastUpdate,
×
2153
                        &i.Policy2Disabled,
×
2154
                        &i.Policy2InboundBaseFeeMsat,
×
2155
                        &i.Policy2InboundFeeRateMilliMsat,
×
2156
                        &i.Policy2MessageFlags,
×
2157
                        &i.Policy2ChannelFlags,
×
2158
                        &i.Policy2Signature,
×
2159
                ); err != nil {
×
2160
                        return nil, err
×
2161
                }
×
2162
                items = append(items, i)
×
2163
        }
2164
        if err := rows.Close(); err != nil {
×
2165
                return nil, err
×
2166
        }
×
2167
        if err := rows.Err(); err != nil {
×
2168
                return nil, err
×
2169
        }
×
2170
        return items, nil
×
2171
}
2172

2173
const listChannelsPaginated = `-- name: ListChannelsPaginated :many
2174
SELECT id, bitcoin_key_1, bitcoin_key_2, outpoint
2175
FROM graph_channels c
2176
WHERE c.version = $1 AND c.id > $2
2177
ORDER BY c.id
2178
LIMIT $3
2179
`
2180

2181
type ListChannelsPaginatedParams struct {
2182
        Version int16
2183
        ID      int64
2184
        Limit   int32
2185
}
2186

2187
type ListChannelsPaginatedRow struct {
2188
        ID          int64
2189
        BitcoinKey1 []byte
2190
        BitcoinKey2 []byte
2191
        Outpoint    string
2192
}
2193

2194
func (q *Queries) ListChannelsPaginated(ctx context.Context, arg ListChannelsPaginatedParams) ([]ListChannelsPaginatedRow, error) {
×
2195
        rows, err := q.db.QueryContext(ctx, listChannelsPaginated, arg.Version, arg.ID, arg.Limit)
×
2196
        if err != nil {
×
2197
                return nil, err
×
2198
        }
×
2199
        defer rows.Close()
×
2200
        var items []ListChannelsPaginatedRow
×
2201
        for rows.Next() {
×
2202
                var i ListChannelsPaginatedRow
×
2203
                if err := rows.Scan(
×
2204
                        &i.ID,
×
2205
                        &i.BitcoinKey1,
×
2206
                        &i.BitcoinKey2,
×
2207
                        &i.Outpoint,
×
2208
                ); err != nil {
×
2209
                        return nil, err
×
2210
                }
×
2211
                items = append(items, i)
×
2212
        }
2213
        if err := rows.Close(); err != nil {
×
2214
                return nil, err
×
2215
        }
×
2216
        if err := rows.Err(); err != nil {
×
2217
                return nil, err
×
2218
        }
×
2219
        return items, nil
×
2220
}
2221

2222
const listChannelsWithPoliciesPaginated = `-- name: ListChannelsWithPoliciesPaginated :many
2223
SELECT
2224
    c.id, c.version, c.scid, c.node_id_1, c.node_id_2, c.outpoint, c.capacity, c.bitcoin_key_1, c.bitcoin_key_2, c.node_1_signature, c.node_2_signature, c.bitcoin_1_signature, c.bitcoin_2_signature,
2225

2226
    -- Join node pubkeys
2227
    n1.pub_key AS node1_pubkey,
2228
    n2.pub_key AS node2_pubkey,
2229

2230
    -- Node 1 policy
2231
    cp1.id AS policy_1_id,
2232
    cp1.node_id AS policy_1_node_id,
2233
    cp1.version AS policy_1_version,
2234
    cp1.timelock AS policy_1_timelock,
2235
    cp1.fee_ppm AS policy_1_fee_ppm,
2236
    cp1.base_fee_msat AS policy_1_base_fee_msat,
2237
    cp1.min_htlc_msat AS policy_1_min_htlc_msat,
2238
    cp1.max_htlc_msat AS policy_1_max_htlc_msat,
2239
    cp1.last_update AS policy_1_last_update,
2240
    cp1.disabled AS policy_1_disabled,
2241
    cp1.inbound_base_fee_msat AS policy1_inbound_base_fee_msat,
2242
    cp1.inbound_fee_rate_milli_msat AS policy1_inbound_fee_rate_milli_msat,
2243
    cp1.message_flags AS policy1_message_flags,
2244
    cp1.channel_flags AS policy1_channel_flags,
2245
    cp1.signature AS policy_1_signature,
2246

2247
    -- Node 2 policy
2248
    cp2.id AS policy_2_id,
2249
    cp2.node_id AS policy_2_node_id,
2250
    cp2.version AS policy_2_version,
2251
    cp2.timelock AS policy_2_timelock,
2252
    cp2.fee_ppm AS policy_2_fee_ppm,
2253
    cp2.base_fee_msat AS policy_2_base_fee_msat,
2254
    cp2.min_htlc_msat AS policy_2_min_htlc_msat,
2255
    cp2.max_htlc_msat AS policy_2_max_htlc_msat,
2256
    cp2.last_update AS policy_2_last_update,
2257
    cp2.disabled AS policy_2_disabled,
2258
    cp2.inbound_base_fee_msat AS policy2_inbound_base_fee_msat,
2259
    cp2.inbound_fee_rate_milli_msat AS policy2_inbound_fee_rate_milli_msat,
2260
    cp2.message_flags AS policy2_message_flags,
2261
    cp2.channel_flags AS policy2_channel_flags,
2262
    cp2.signature AS policy_2_signature
2263

2264
FROM graph_channels c
2265
JOIN graph_nodes n1 ON c.node_id_1 = n1.id
2266
JOIN graph_nodes n2 ON c.node_id_2 = n2.id
2267
LEFT JOIN graph_channel_policies cp1
2268
    ON cp1.channel_id = c.id AND cp1.node_id = c.node_id_1 AND cp1.version = c.version
2269
LEFT JOIN graph_channel_policies cp2
2270
    ON cp2.channel_id = c.id AND cp2.node_id = c.node_id_2 AND cp2.version = c.version
2271
WHERE c.version = $1 AND c.id > $2
2272
ORDER BY c.id
2273
LIMIT $3
2274
`
2275

2276
type ListChannelsWithPoliciesPaginatedParams struct {
2277
        Version int16
2278
        ID      int64
2279
        Limit   int32
2280
}
2281

2282
type ListChannelsWithPoliciesPaginatedRow struct {
2283
        GraphChannel                   GraphChannel
2284
        Node1Pubkey                    []byte
2285
        Node2Pubkey                    []byte
2286
        Policy1ID                      sql.NullInt64
2287
        Policy1NodeID                  sql.NullInt64
2288
        Policy1Version                 sql.NullInt16
2289
        Policy1Timelock                sql.NullInt32
2290
        Policy1FeePpm                  sql.NullInt64
2291
        Policy1BaseFeeMsat             sql.NullInt64
2292
        Policy1MinHtlcMsat             sql.NullInt64
2293
        Policy1MaxHtlcMsat             sql.NullInt64
2294
        Policy1LastUpdate              sql.NullInt64
2295
        Policy1Disabled                sql.NullBool
2296
        Policy1InboundBaseFeeMsat      sql.NullInt64
2297
        Policy1InboundFeeRateMilliMsat sql.NullInt64
2298
        Policy1MessageFlags            sql.NullInt16
2299
        Policy1ChannelFlags            sql.NullInt16
2300
        Policy1Signature               []byte
2301
        Policy2ID                      sql.NullInt64
2302
        Policy2NodeID                  sql.NullInt64
2303
        Policy2Version                 sql.NullInt16
2304
        Policy2Timelock                sql.NullInt32
2305
        Policy2FeePpm                  sql.NullInt64
2306
        Policy2BaseFeeMsat             sql.NullInt64
2307
        Policy2MinHtlcMsat             sql.NullInt64
2308
        Policy2MaxHtlcMsat             sql.NullInt64
2309
        Policy2LastUpdate              sql.NullInt64
2310
        Policy2Disabled                sql.NullBool
2311
        Policy2InboundBaseFeeMsat      sql.NullInt64
2312
        Policy2InboundFeeRateMilliMsat sql.NullInt64
2313
        Policy2MessageFlags            sql.NullInt16
2314
        Policy2ChannelFlags            sql.NullInt16
2315
        Policy2Signature               []byte
2316
}
2317

2318
func (q *Queries) ListChannelsWithPoliciesPaginated(ctx context.Context, arg ListChannelsWithPoliciesPaginatedParams) ([]ListChannelsWithPoliciesPaginatedRow, error) {
×
2319
        rows, err := q.db.QueryContext(ctx, listChannelsWithPoliciesPaginated, arg.Version, arg.ID, arg.Limit)
×
2320
        if err != nil {
×
2321
                return nil, err
×
2322
        }
×
2323
        defer rows.Close()
×
2324
        var items []ListChannelsWithPoliciesPaginatedRow
×
2325
        for rows.Next() {
×
2326
                var i ListChannelsWithPoliciesPaginatedRow
×
2327
                if err := rows.Scan(
×
2328
                        &i.GraphChannel.ID,
×
2329
                        &i.GraphChannel.Version,
×
2330
                        &i.GraphChannel.Scid,
×
2331
                        &i.GraphChannel.NodeID1,
×
2332
                        &i.GraphChannel.NodeID2,
×
2333
                        &i.GraphChannel.Outpoint,
×
2334
                        &i.GraphChannel.Capacity,
×
2335
                        &i.GraphChannel.BitcoinKey1,
×
2336
                        &i.GraphChannel.BitcoinKey2,
×
2337
                        &i.GraphChannel.Node1Signature,
×
2338
                        &i.GraphChannel.Node2Signature,
×
2339
                        &i.GraphChannel.Bitcoin1Signature,
×
2340
                        &i.GraphChannel.Bitcoin2Signature,
×
2341
                        &i.Node1Pubkey,
×
2342
                        &i.Node2Pubkey,
×
2343
                        &i.Policy1ID,
×
2344
                        &i.Policy1NodeID,
×
2345
                        &i.Policy1Version,
×
2346
                        &i.Policy1Timelock,
×
2347
                        &i.Policy1FeePpm,
×
2348
                        &i.Policy1BaseFeeMsat,
×
2349
                        &i.Policy1MinHtlcMsat,
×
2350
                        &i.Policy1MaxHtlcMsat,
×
2351
                        &i.Policy1LastUpdate,
×
2352
                        &i.Policy1Disabled,
×
2353
                        &i.Policy1InboundBaseFeeMsat,
×
2354
                        &i.Policy1InboundFeeRateMilliMsat,
×
2355
                        &i.Policy1MessageFlags,
×
2356
                        &i.Policy1ChannelFlags,
×
2357
                        &i.Policy1Signature,
×
2358
                        &i.Policy2ID,
×
2359
                        &i.Policy2NodeID,
×
2360
                        &i.Policy2Version,
×
2361
                        &i.Policy2Timelock,
×
2362
                        &i.Policy2FeePpm,
×
2363
                        &i.Policy2BaseFeeMsat,
×
2364
                        &i.Policy2MinHtlcMsat,
×
2365
                        &i.Policy2MaxHtlcMsat,
×
2366
                        &i.Policy2LastUpdate,
×
2367
                        &i.Policy2Disabled,
×
2368
                        &i.Policy2InboundBaseFeeMsat,
×
2369
                        &i.Policy2InboundFeeRateMilliMsat,
×
2370
                        &i.Policy2MessageFlags,
×
2371
                        &i.Policy2ChannelFlags,
×
2372
                        &i.Policy2Signature,
×
2373
                ); err != nil {
×
2374
                        return nil, err
×
2375
                }
×
2376
                items = append(items, i)
×
2377
        }
2378
        if err := rows.Close(); err != nil {
×
2379
                return nil, err
×
2380
        }
×
2381
        if err := rows.Err(); err != nil {
×
2382
                return nil, err
×
2383
        }
×
2384
        return items, nil
×
2385
}
2386

2387
const listNodeIDsAndPubKeys = `-- name: ListNodeIDsAndPubKeys :many
2388
SELECT id, pub_key
2389
FROM graph_nodes
2390
WHERE version = $1  AND id > $2
2391
ORDER BY id
2392
LIMIT $3
2393
`
2394

2395
type ListNodeIDsAndPubKeysParams struct {
2396
        Version int16
2397
        ID      int64
2398
        Limit   int32
2399
}
2400

2401
type ListNodeIDsAndPubKeysRow struct {
2402
        ID     int64
2403
        PubKey []byte
2404
}
2405

2406
func (q *Queries) ListNodeIDsAndPubKeys(ctx context.Context, arg ListNodeIDsAndPubKeysParams) ([]ListNodeIDsAndPubKeysRow, error) {
×
2407
        rows, err := q.db.QueryContext(ctx, listNodeIDsAndPubKeys, arg.Version, arg.ID, arg.Limit)
×
2408
        if err != nil {
×
2409
                return nil, err
×
2410
        }
×
2411
        defer rows.Close()
×
2412
        var items []ListNodeIDsAndPubKeysRow
×
2413
        for rows.Next() {
×
2414
                var i ListNodeIDsAndPubKeysRow
×
2415
                if err := rows.Scan(&i.ID, &i.PubKey); err != nil {
×
2416
                        return nil, err
×
2417
                }
×
2418
                items = append(items, i)
×
2419
        }
2420
        if err := rows.Close(); err != nil {
×
2421
                return nil, err
×
2422
        }
×
2423
        if err := rows.Err(); err != nil {
×
2424
                return nil, err
×
2425
        }
×
2426
        return items, nil
×
2427
}
2428

2429
const listNodesPaginated = `-- name: ListNodesPaginated :many
2430
SELECT id, version, pub_key, alias, last_update, color, signature
2431
FROM graph_nodes
2432
WHERE version = $1 AND id > $2
2433
ORDER BY id
2434
LIMIT $3
2435
`
2436

2437
type ListNodesPaginatedParams struct {
2438
        Version int16
2439
        ID      int64
2440
        Limit   int32
2441
}
2442

2443
func (q *Queries) ListNodesPaginated(ctx context.Context, arg ListNodesPaginatedParams) ([]GraphNode, error) {
×
2444
        rows, err := q.db.QueryContext(ctx, listNodesPaginated, arg.Version, arg.ID, arg.Limit)
×
2445
        if err != nil {
×
2446
                return nil, err
×
2447
        }
×
2448
        defer rows.Close()
×
2449
        var items []GraphNode
×
2450
        for rows.Next() {
×
2451
                var i GraphNode
×
2452
                if err := rows.Scan(
×
2453
                        &i.ID,
×
2454
                        &i.Version,
×
2455
                        &i.PubKey,
×
2456
                        &i.Alias,
×
2457
                        &i.LastUpdate,
×
2458
                        &i.Color,
×
2459
                        &i.Signature,
×
2460
                ); err != nil {
×
2461
                        return nil, err
×
2462
                }
×
2463
                items = append(items, i)
×
2464
        }
2465
        if err := rows.Close(); err != nil {
×
2466
                return nil, err
×
2467
        }
×
2468
        if err := rows.Err(); err != nil {
×
2469
                return nil, err
×
2470
        }
×
2471
        return items, nil
×
2472
}
2473

2474
const upsertEdgePolicy = `-- name: UpsertEdgePolicy :one
2475
/* ─────────────────────────────────────────────
2476
   graph_channel_policies table queries
2477
   ─────────────────────────────────────────────
2478
*/
2479

2480
INSERT INTO graph_channel_policies (
2481
    version, channel_id, node_id, timelock, fee_ppm,
2482
    base_fee_msat, min_htlc_msat, last_update, disabled,
2483
    max_htlc_msat, inbound_base_fee_msat,
2484
    inbound_fee_rate_milli_msat, message_flags, channel_flags,
2485
    signature
2486
) VALUES  (
2487
    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
2488
)
2489
ON CONFLICT (channel_id, node_id, version)
2490
    -- Update the following fields if a conflict occurs on channel_id,
2491
    -- node_id, and version.
2492
    DO UPDATE SET
2493
        timelock = EXCLUDED.timelock,
2494
        fee_ppm = EXCLUDED.fee_ppm,
2495
        base_fee_msat = EXCLUDED.base_fee_msat,
2496
        min_htlc_msat = EXCLUDED.min_htlc_msat,
2497
        last_update = EXCLUDED.last_update,
2498
        disabled = EXCLUDED.disabled,
2499
        max_htlc_msat = EXCLUDED.max_htlc_msat,
2500
        inbound_base_fee_msat = EXCLUDED.inbound_base_fee_msat,
2501
        inbound_fee_rate_milli_msat = EXCLUDED.inbound_fee_rate_milli_msat,
2502
        message_flags = EXCLUDED.message_flags,
2503
        channel_flags = EXCLUDED.channel_flags,
2504
        signature = EXCLUDED.signature
2505
WHERE EXCLUDED.last_update > graph_channel_policies.last_update
2506
RETURNING id
2507
`
2508

2509
type UpsertEdgePolicyParams struct {
2510
        Version                 int16
2511
        ChannelID               int64
2512
        NodeID                  int64
2513
        Timelock                int32
2514
        FeePpm                  int64
2515
        BaseFeeMsat             int64
2516
        MinHtlcMsat             int64
2517
        LastUpdate              sql.NullInt64
2518
        Disabled                sql.NullBool
2519
        MaxHtlcMsat             sql.NullInt64
2520
        InboundBaseFeeMsat      sql.NullInt64
2521
        InboundFeeRateMilliMsat sql.NullInt64
2522
        MessageFlags            sql.NullInt16
2523
        ChannelFlags            sql.NullInt16
2524
        Signature               []byte
2525
}
2526

2527
func (q *Queries) UpsertEdgePolicy(ctx context.Context, arg UpsertEdgePolicyParams) (int64, error) {
×
2528
        row := q.db.QueryRowContext(ctx, upsertEdgePolicy,
×
2529
                arg.Version,
×
2530
                arg.ChannelID,
×
2531
                arg.NodeID,
×
2532
                arg.Timelock,
×
2533
                arg.FeePpm,
×
2534
                arg.BaseFeeMsat,
×
2535
                arg.MinHtlcMsat,
×
2536
                arg.LastUpdate,
×
2537
                arg.Disabled,
×
2538
                arg.MaxHtlcMsat,
×
2539
                arg.InboundBaseFeeMsat,
×
2540
                arg.InboundFeeRateMilliMsat,
×
2541
                arg.MessageFlags,
×
2542
                arg.ChannelFlags,
×
2543
                arg.Signature,
×
2544
        )
×
2545
        var id int64
×
2546
        err := row.Scan(&id)
×
2547
        return id, err
×
2548
}
×
2549

2550
const upsertNode = `-- name: UpsertNode :one
2551
/* ─────────────────────────────────────────────
2552
   graph_nodes table queries
2553
   ───────────────────────────��─────────────────
2554
*/
2555

2556
INSERT INTO graph_nodes (
2557
    version, pub_key, alias, last_update, color, signature
2558
) VALUES (
2559
    $1, $2, $3, $4, $5, $6
2560
)
2561
ON CONFLICT (pub_key, version)
2562
    -- Update the following fields if a conflict occurs on pub_key
2563
    -- and version.
2564
    DO UPDATE SET
2565
        alias = EXCLUDED.alias,
2566
        last_update = EXCLUDED.last_update,
2567
        color = EXCLUDED.color,
2568
        signature = EXCLUDED.signature
2569
WHERE graph_nodes.last_update IS NULL
2570
    OR EXCLUDED.last_update > graph_nodes.last_update
2571
RETURNING id
2572
`
2573

2574
type UpsertNodeParams struct {
2575
        Version    int16
2576
        PubKey     []byte
2577
        Alias      sql.NullString
2578
        LastUpdate sql.NullInt64
2579
        Color      sql.NullString
2580
        Signature  []byte
2581
}
2582

2583
func (q *Queries) UpsertNode(ctx context.Context, arg UpsertNodeParams) (int64, error) {
×
2584
        row := q.db.QueryRowContext(ctx, upsertNode,
×
2585
                arg.Version,
×
2586
                arg.PubKey,
×
2587
                arg.Alias,
×
2588
                arg.LastUpdate,
×
2589
                arg.Color,
×
2590
                arg.Signature,
×
2591
        )
×
2592
        var id int64
×
2593
        err := row.Scan(&id)
×
2594
        return id, err
×
2595
}
×
2596

2597
const upsertNodeExtraType = `-- name: UpsertNodeExtraType :exec
2598
/* ─────────────────────────────────────────────
2599
   graph_node_extra_types table queries
2600
   ─────────────────────────────────────────────
2601
*/
2602

2603
INSERT INTO graph_node_extra_types (
2604
    node_id, type, value
2605
)
2606
VALUES ($1, $2, $3)
2607
ON CONFLICT (type, node_id)
2608
    -- Update the value if a conflict occurs on type
2609
    -- and node_id.
2610
    DO UPDATE SET value = EXCLUDED.value
2611
`
2612

2613
type UpsertNodeExtraTypeParams struct {
2614
        NodeID int64
2615
        Type   int64
2616
        Value  []byte
2617
}
2618

2619
func (q *Queries) UpsertNodeExtraType(ctx context.Context, arg UpsertNodeExtraTypeParams) error {
×
2620
        _, err := q.db.ExecContext(ctx, upsertNodeExtraType, arg.NodeID, arg.Type, arg.Value)
×
2621
        return err
×
2622
}
×
2623

2624
const upsertPruneLogEntry = `-- name: UpsertPruneLogEntry :exec
2625
/* ───────────────────────────���─────────────────
2626
    graph_prune_log table queries
2627
    ─────────────────────────────────────────────
2628
*/
2629

2630
INSERT INTO graph_prune_log (
2631
    block_height, block_hash
2632
) VALUES (
2633
    $1, $2
2634
)
2635
ON CONFLICT(block_height) DO UPDATE SET
2636
    block_hash = EXCLUDED.block_hash
2637
`
2638

2639
type UpsertPruneLogEntryParams struct {
2640
        BlockHeight int64
2641
        BlockHash   []byte
2642
}
2643

2644
func (q *Queries) UpsertPruneLogEntry(ctx context.Context, arg UpsertPruneLogEntryParams) error {
×
2645
        _, err := q.db.ExecContext(ctx, upsertPruneLogEntry, arg.BlockHeight, arg.BlockHash)
×
2646
        return err
×
2647
}
×
2648

2649
const upsertZombieChannel = `-- name: UpsertZombieChannel :exec
2650
/* ─────────────────────────────────────────────
2651
   graph_zombie_channels table queries
2652
   ─────────────────────────────────────────────
2653
*/
2654

2655
INSERT INTO graph_zombie_channels (scid, version, node_key_1, node_key_2)
2656
VALUES ($1, $2, $3, $4)
2657
ON CONFLICT (scid, version)
2658
DO UPDATE SET
2659
    -- If a conflict exists for the SCID and version pair, then we
2660
    -- update the node keys.
2661
    node_key_1 = COALESCE(EXCLUDED.node_key_1, graph_zombie_channels.node_key_1),
2662
    node_key_2 = COALESCE(EXCLUDED.node_key_2, graph_zombie_channels.node_key_2)
2663
`
2664

2665
type UpsertZombieChannelParams struct {
2666
        Scid     []byte
2667
        Version  int16
2668
        NodeKey1 []byte
2669
        NodeKey2 []byte
2670
}
2671

2672
func (q *Queries) UpsertZombieChannel(ctx context.Context, arg UpsertZombieChannelParams) error {
×
2673
        _, err := q.db.ExecContext(ctx, upsertZombieChannel,
×
2674
                arg.Scid,
×
2675
                arg.Version,
×
2676
                arg.NodeKey1,
×
2677
                arg.NodeKey2,
×
2678
        )
×
2679
        return err
×
2680
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc