graph/db+sqldb: impl PutClosedScid and IsClosedScid

This commit is contained in:
Elle Mouton
2025-06-11 17:55:28 +02:00
parent 5effa96766
commit 933ab3c6b7
5 changed files with 101 additions and 1 deletions

View File

@ -1555,6 +1555,22 @@ func (q *Queries) InsertChannelFeature(ctx context.Context, arg InsertChannelFea
return err
}
const insertClosedChannel = `-- name: InsertClosedChannel :exec
/* ─────────────────────────────────────────────
closed_scid table queries
────────────────────────────────────────────-
*/
INSERT INTO closed_scids (scid)
VALUES ($1)
ON CONFLICT (scid) DO NOTHING
`
func (q *Queries) InsertClosedChannel(ctx context.Context, scid []byte) error {
_, err := q.db.ExecContext(ctx, insertClosedChannel, scid)
return err
}
const insertNodeAddress = `-- name: InsertNodeAddress :exec
/* ─────────────────────────────────────────────
node_addresses table queries
@ -1611,6 +1627,21 @@ func (q *Queries) InsertNodeFeature(ctx context.Context, arg InsertNodeFeaturePa
return err
}
const isClosedChannel = `-- name: IsClosedChannel :one
SELECT EXISTS (
SELECT 1
FROM closed_scids
WHERE scid = $1
)
`
func (q *Queries) IsClosedChannel(ctx context.Context, scid []byte) (bool, error) {
row := q.db.QueryRowContext(ctx, isClosedChannel, scid)
var exists bool
err := row.Scan(&exists)
return exists, err
}
const isPublicV1Node = `-- name: IsPublicV1Node :one
SELECT EXISTS (
SELECT 1