mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 21:46:37 +02:00
graph/db+sqldb: impl PutClosedScid and IsClosedScid
This commit is contained in:
@@ -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
|
||||
|
@@ -80,6 +80,7 @@ type Querier interface {
|
||||
InsertAMPSubInvoiceHTLC(ctx context.Context, arg InsertAMPSubInvoiceHTLCParams) error
|
||||
InsertChanPolicyExtraType(ctx context.Context, arg InsertChanPolicyExtraTypeParams) error
|
||||
InsertChannelFeature(ctx context.Context, arg InsertChannelFeatureParams) error
|
||||
InsertClosedChannel(ctx context.Context, scid []byte) error
|
||||
InsertInvoice(ctx context.Context, arg InsertInvoiceParams) (int64, error)
|
||||
InsertInvoiceFeature(ctx context.Context, arg InsertInvoiceFeatureParams) error
|
||||
InsertInvoiceHTLC(ctx context.Context, arg InsertInvoiceHTLCParams) (int64, error)
|
||||
@@ -88,6 +89,7 @@ type Querier interface {
|
||||
InsertMigratedInvoice(ctx context.Context, arg InsertMigratedInvoiceParams) (int64, error)
|
||||
InsertNodeAddress(ctx context.Context, arg InsertNodeAddressParams) error
|
||||
InsertNodeFeature(ctx context.Context, arg InsertNodeFeatureParams) error
|
||||
IsClosedChannel(ctx context.Context, scid []byte) (bool, error)
|
||||
IsPublicV1Node(ctx context.Context, pubKey []byte) (bool, error)
|
||||
IsZombieChannel(ctx context.Context, arg IsZombieChannelParams) (bool, error)
|
||||
ListChannelsByNodeID(ctx context.Context, arg ListChannelsByNodeIDParams) ([]ListChannelsByNodeIDRow, error)
|
||||
|
@@ -709,3 +709,20 @@ LIMIT 1;
|
||||
DELETE FROM prune_log
|
||||
WHERE block_height >= @start_height
|
||||
AND block_height <= @end_height;
|
||||
|
||||
/* ─────────────────────────────────────────────
|
||||
closed_scid table queries
|
||||
────────────────────────────────────────────-
|
||||
*/
|
||||
|
||||
-- name: InsertClosedChannel :exec
|
||||
INSERT INTO closed_scids (scid)
|
||||
VALUES ($1)
|
||||
ON CONFLICT (scid) DO NOTHING;
|
||||
|
||||
-- name: IsClosedChannel :one
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM closed_scids
|
||||
WHERE scid = $1
|
||||
);
|
||||
|
Reference in New Issue
Block a user