graph/db+sqldb: implement AddEdgeProof

And run `TestAddEdgeProof` against the SQL backends.
This commit is contained in:
Elle Mouton
2025-06-11 17:52:20 +02:00
parent 5d926b39a6
commit d46552f5ad
5 changed files with 88 additions and 1 deletions

View File

@ -26,6 +26,34 @@ func (q *Queries) AddSourceNode(ctx context.Context, nodeID int64) error {
return err
}
const addV1ChannelProof = `-- name: AddV1ChannelProof :execresult
UPDATE channels
SET node_1_signature = $2,
node_2_signature = $3,
bitcoin_1_signature = $4,
bitcoin_2_signature = $5
WHERE scid = $1
AND version = 1
`
type AddV1ChannelProofParams struct {
Scid []byte
Node1Signature []byte
Node2Signature []byte
Bitcoin1Signature []byte
Bitcoin2Signature []byte
}
func (q *Queries) AddV1ChannelProof(ctx context.Context, arg AddV1ChannelProofParams) (sql.Result, error) {
return q.db.ExecContext(ctx, addV1ChannelProof,
arg.Scid,
arg.Node1Signature,
arg.Node2Signature,
arg.Bitcoin1Signature,
arg.Bitcoin2Signature,
)
}
const countZombieChannels = `-- name: CountZombieChannels :one
SELECT COUNT(*)
FROM zombie_channels

View File

@ -12,6 +12,7 @@ import (
type Querier interface {
AddSourceNode(ctx context.Context, nodeID int64) error
AddV1ChannelProof(ctx context.Context, arg AddV1ChannelProofParams) (sql.Result, error)
ClearKVInvoiceHashIndex(ctx context.Context) error
CountZombieChannels(ctx context.Context, version int16) (int64, error)
CreateChannel(ctx context.Context, arg CreateChannelParams) (int64, error)

View File

@ -208,6 +208,15 @@ INSERT INTO channels (
)
RETURNING id;
-- name: AddV1ChannelProof :execresult
UPDATE channels
SET node_1_signature = $2,
node_2_signature = $3,
bitcoin_1_signature = $4,
bitcoin_2_signature = $5
WHERE scid = $1
AND version = 1;
-- name: GetChannelsBySCIDRange :many
SELECT sqlc.embed(c),
n1.pub_key AS node1_pub_key,