mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-29 00:02:32 +02:00
graph/db: migrate prune log
This commit expands the `MigrateGraphToSQL` to include migration of the prune log.
This commit is contained in:
@@ -1350,6 +1350,19 @@ func (q *Queries) GetNodesByLastUpdateRange(ctx context.Context, arg GetNodesByL
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getPruneHashByHeight = `-- name: GetPruneHashByHeight :one
|
||||
SELECT block_hash
|
||||
FROM prune_log
|
||||
WHERE block_height = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetPruneHashByHeight(ctx context.Context, blockHeight int64) ([]byte, error) {
|
||||
row := q.db.QueryRowContext(ctx, getPruneHashByHeight, blockHeight)
|
||||
var block_hash []byte
|
||||
err := row.Scan(&block_hash)
|
||||
return block_hash, err
|
||||
}
|
||||
|
||||
const getPruneTip = `-- name: GetPruneTip :one
|
||||
SELECT block_height, block_hash
|
||||
FROM prune_log
|
||||
|
@@ -63,6 +63,7 @@ type Querier interface {
|
||||
GetNodeFeaturesByPubKey(ctx context.Context, arg GetNodeFeaturesByPubKeyParams) ([]int32, error)
|
||||
GetNodeIDByPubKey(ctx context.Context, arg GetNodeIDByPubKeyParams) (int64, error)
|
||||
GetNodesByLastUpdateRange(ctx context.Context, arg GetNodesByLastUpdateRangeParams) ([]Node, error)
|
||||
GetPruneHashByHeight(ctx context.Context, blockHeight int64) ([]byte, error)
|
||||
GetPruneTip(ctx context.Context) (PruneLog, error)
|
||||
GetPublicV1ChannelsBySCID(ctx context.Context, arg GetPublicV1ChannelsBySCIDParams) ([]Channel, error)
|
||||
GetSCIDByOutpoint(ctx context.Context, arg GetSCIDByOutpointParams) ([]byte, error)
|
||||
|
@@ -728,6 +728,11 @@ FROM prune_log
|
||||
ORDER BY block_height DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetPruneHashByHeight :one
|
||||
SELECT block_hash
|
||||
FROM prune_log
|
||||
WHERE block_height = $1;
|
||||
|
||||
-- name: DeletePruneLogEntriesInRange :exec
|
||||
DELETE FROM prune_log
|
||||
WHERE block_height >= @start_height
|
||||
|
Reference in New Issue
Block a user