graph/db: version disabled channel IDs
Add a gossip version parameter to DisabledChannelIDs in the Store interface and both implementations. Add a new version-filtered SQL query and update the builder caller.
This commit is contained in:
9 files changed
+113
-18
No files matched your search
@@ -2410,6 +2410,41 @@ func (q *Queries) GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getV2DisabledSCIDs = `-- name: GetV2DisabledSCIDs :many
|
||||
SELECT c.scid
|
||||
FROM graph_channels c
|
||||
JOIN graph_channel_policies cp ON cp.channel_id = c.id
|
||||
WHERE COALESCE(cp.disable_flags, 0) != 0
|
||||
AND c.version = 2
|
||||
GROUP BY c.scid
|
||||
HAVING COUNT(*) > 1
|
||||
`
|
||||
|
||||
// NOTE: this is V2 specific since V2 uses a disable flag
|
||||
// bit vector instead of a single boolean.
|
||||
func (q *Queries) GetV2DisabledSCIDs(ctx context.Context) ([][]byte, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getV2DisabledSCIDs)
|
||||
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 graph_zombie_channels
|
||||
|
||||
@@ -83,6 +83,9 @@ type Querier interface {
|
||||
// structure will have a more complex disabled bit vector
|
||||
// and so the query for V2 may differ.
|
||||
GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error)
|
||||
// NOTE: this is V2 specific since V2 uses a disable flag
|
||||
// bit vector instead of a single boolean.
|
||||
GetV2DisabledSCIDs(ctx context.Context) ([][]byte, error)
|
||||
GetZombieChannel(ctx context.Context, arg GetZombieChannelParams) (GraphZombieChannel, error)
|
||||
GetZombieChannelsSCIDs(ctx context.Context, arg GetZombieChannelsSCIDsParams) ([]GraphZombieChannel, error)
|
||||
HighestSCID(ctx context.Context, version int16) ([]byte, error)
|
||||
|
||||
@@ -1066,6 +1066,17 @@ AND c.version = 1
|
||||
GROUP BY c.scid
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
-- name: GetV2DisabledSCIDs :many
|
||||
SELECT c.scid
|
||||
FROM graph_channels c
|
||||
JOIN graph_channel_policies cp ON cp.channel_id = c.id
|
||||
-- NOTE: this is V2 specific since V2 uses a disable flag
|
||||
-- bit vector instead of a single boolean.
|
||||
WHERE COALESCE(cp.disable_flags, 0) != 0
|
||||
AND c.version = 2
|
||||
GROUP BY c.scid
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
-- name: DeleteChannelPolicyExtraTypes :exec
|
||||
DELETE FROM graph_channel_policy_extra_types
|
||||
WHERE channel_policy_id = $1;
|
||||
|
||||
Reference in new issue
Block a user