graph/db+sqldb: implement HasChannelEdge and ChannelID

And run `TestEdgeInfoUpdates` against our SQL backends.
This commit is contained in:
Elle Mouton
2025-06-11 17:20:44 +02:00
parent 4fad4a7023
commit 13bf6a549f
5 changed files with 220 additions and 1 deletions

View File

@ -1167,6 +1167,23 @@ func (q *Queries) GetPublicV1ChannelsBySCID(ctx context.Context, arg GetPublicV1
return items, nil
}
const getSCIDByOutpoint = `-- name: GetSCIDByOutpoint :one
SELECT scid from channels
WHERE outpoint = $1 AND version = $2
`
type GetSCIDByOutpointParams struct {
Outpoint string
Version int16
}
func (q *Queries) GetSCIDByOutpoint(ctx context.Context, arg GetSCIDByOutpointParams) ([]byte, error) {
row := q.db.QueryRowContext(ctx, getSCIDByOutpoint, arg.Outpoint, arg.Version)
var scid []byte
err := row.Scan(&scid)
return scid, err
}
const getSourceNodesByVersion = `-- name: GetSourceNodesByVersion :many
SELECT sn.node_id, n.pub_key
FROM source_nodes sn

View File

@ -58,6 +58,7 @@ type Querier interface {
GetNodeIDByPubKey(ctx context.Context, arg GetNodeIDByPubKeyParams) (int64, error)
GetNodesByLastUpdateRange(ctx context.Context, arg GetNodesByLastUpdateRangeParams) ([]Node, error)
GetPublicV1ChannelsBySCID(ctx context.Context, arg GetPublicV1ChannelsBySCIDParams) ([]Channel, error)
GetSCIDByOutpoint(ctx context.Context, arg GetSCIDByOutpointParams) ([]byte, error)
GetSourceNodesByVersion(ctx context.Context, version int16) ([]GetSourceNodesByVersionRow, error)
GetZombieChannel(ctx context.Context, arg GetZombieChannelParams) (ZombieChannel, error)
HighestSCID(ctx context.Context, version int16) ([]byte, error)

View File

@ -206,6 +206,10 @@ SELECT
FROM channel_extra_types cet
WHERE cet.channel_id = $1;
-- name: GetSCIDByOutpoint :one
SELECT scid from channels
WHERE outpoint = $1 AND version = $2;
-- name: GetChannelsByPolicyLastUpdateRange :many
SELECT
sqlc.embed(c),