graph/db+sqldb: add HighestChanID to SQLStore

This commit is contained in:
Elle Mouton
2025-05-24 15:21:56 +02:00
parent d93d104a66
commit cf542458bd
5 changed files with 54 additions and 1 deletions

View File

@ -429,6 +429,21 @@ func (q *Queries) GetSourceNodesByVersion(ctx context.Context, version int16) ([
return items, nil
}
const highestSCID = `-- name: HighestSCID :one
SELECT scid
FROM channels
WHERE version = $1
ORDER BY scid DESC
LIMIT 1
`
func (q *Queries) HighestSCID(ctx context.Context, version int16) ([]byte, error) {
row := q.db.QueryRowContext(ctx, highestSCID, version)
var scid []byte
err := row.Scan(&scid)
return scid, err
}
const insertChannelFeature = `-- name: InsertChannelFeature :exec
/* ─────────────────────────────────────────────
channel_features table queries

View File

@ -46,6 +46,7 @@ type Querier interface {
GetNodeFeaturesByPubKey(ctx context.Context, arg GetNodeFeaturesByPubKeyParams) ([]int32, error)
GetNodesByLastUpdateRange(ctx context.Context, arg GetNodesByLastUpdateRangeParams) ([]Node, error)
GetSourceNodesByVersion(ctx context.Context, version int16) ([]GetSourceNodesByVersionRow, error)
HighestSCID(ctx context.Context, version int16) ([]byte, error)
InsertAMPSubInvoice(ctx context.Context, arg InsertAMPSubInvoiceParams) error
InsertAMPSubInvoiceHTLC(ctx context.Context, arg InsertAMPSubInvoiceHTLCParams) error
InsertChannelFeature(ctx context.Context, arg InsertChannelFeatureParams) error

View File

@ -153,6 +153,13 @@ RETURNING id;
SELECT * FROM channels
WHERE scid = $1 AND version = $2;
-- name: HighestSCID :one
SELECT scid
FROM channels
WHERE version = $1
ORDER BY scid DESC
LIMIT 1;
/* ─────────────────────────────────────────────
channel_features table queries
─────────────────────────────────────────────