mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-24 03:26:23 +02:00
graph/db+sqldb: impl DisabledChannelIDs
Which lets us run `TestDisabledChannelIDs` against our SQL DB backends.
This commit is contained in:
@@ -1219,6 +1219,43 @@ func (q *Queries) GetSourceNodesByVersion(ctx context.Context, version int16) ([
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getV1DisabledSCIDs = `-- name: GetV1DisabledSCIDs :many
|
||||
SELECT c.scid
|
||||
FROM channels c
|
||||
JOIN channel_policies cp ON cp.channel_id = c.id
|
||||
WHERE cp.disabled = true
|
||||
AND c.version = 1
|
||||
GROUP BY c.scid
|
||||
HAVING COUNT(*) > 1
|
||||
`
|
||||
|
||||
// NOTE: this is V1 specific since for V1, disabled is a
|
||||
// simple, single boolean. The proposed V2 policy
|
||||
// structure will have a more complex disabled bit vector
|
||||
// and so the query for V2 may differ.
|
||||
func (q *Queries) GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getV1DisabledSCIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items [][]byte
|
||||
for rows.Next() {
|
||||
var scid []byte
|
||||
if err := rows.Scan(&scid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, scid)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getZombieChannel = `-- name: GetZombieChannel :one
|
||||
SELECT scid, version, node_key_1, node_key_2
|
||||
FROM zombie_channels
|
||||
|
@@ -60,6 +60,11 @@ type Querier interface {
|
||||
GetPublicV1ChannelsBySCID(ctx context.Context, arg GetPublicV1ChannelsBySCIDParams) ([]Channel, error)
|
||||
GetSCIDByOutpoint(ctx context.Context, arg GetSCIDByOutpointParams) ([]byte, error)
|
||||
GetSourceNodesByVersion(ctx context.Context, version int16) ([]GetSourceNodesByVersionRow, error)
|
||||
// NOTE: this is V1 specific since for V1, disabled is a
|
||||
// simple, single boolean. The proposed V2 policy
|
||||
// structure will have a more complex disabled bit vector
|
||||
// and so the query for V2 may differ.
|
||||
GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error)
|
||||
GetZombieChannel(ctx context.Context, arg GetZombieChannelParams) (ZombieChannel, error)
|
||||
HighestSCID(ctx context.Context, version int16) ([]byte, error)
|
||||
InsertAMPSubInvoice(ctx context.Context, arg InsertAMPSubInvoiceParams) error
|
||||
|
@@ -573,6 +573,19 @@ JOIN channel_policy_extra_types cpet
|
||||
ON cp.id = cpet.channel_policy_id
|
||||
WHERE cp.id = $1 OR cp.id = $2;
|
||||
|
||||
-- name: GetV1DisabledSCIDs :many
|
||||
SELECT c.scid
|
||||
FROM channels c
|
||||
JOIN channel_policies cp ON cp.channel_id = c.id
|
||||
-- NOTE: this is V1 specific since for V1, disabled is a
|
||||
-- simple, single boolean. The proposed V2 policy
|
||||
-- structure will have a more complex disabled bit vector
|
||||
-- and so the query for V2 may differ.
|
||||
WHERE cp.disabled = true
|
||||
AND c.version = 1
|
||||
GROUP BY c.scid
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
-- name: DeleteChannelPolicyExtraTypes :exec
|
||||
DELETE FROM channel_policy_extra_types
|
||||
WHERE channel_policy_id = $1;
|
||||
|
Reference in New Issue
Block a user