mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: selected swap amount migration
The selected_amount column of all previous swaps is filled with the total value of deposits that partook in these swaps.
This commit is contained in:
parent
23f6c24c0c
commit
2ee772b251
8 changed files with 265 additions and 7 deletions
|
|
@ -65,6 +65,7 @@ type Querier interface {
|
|||
InsertSwapUpdate(ctx context.Context, arg InsertSwapUpdateParams) error
|
||||
IsStored(ctx context.Context, swapHash []byte) (bool, error)
|
||||
MapDepositToSwap(ctx context.Context, arg MapDepositToSwapParams) error
|
||||
OverrideSelectedSwapAmount(ctx context.Context, arg OverrideSelectedSwapAmountParams) error
|
||||
OverrideSwapCosts(ctx context.Context, arg OverrideSwapCostsParams) error
|
||||
SwapHashForDepositID(ctx context.Context, depositID []byte) ([]byte, error)
|
||||
UpdateBatch(ctx context.Context, arg UpdateBatchParams) error
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@ SELECT EXISTS (
|
|||
WHERE swap_hash = $1
|
||||
);
|
||||
|
||||
-- name: OverrideSelectedSwapAmount :exec
|
||||
UPDATE static_address_swaps
|
||||
SET
|
||||
selected_amount = $2
|
||||
WHERE swap_hash = $1;
|
||||
|
||||
-- name: MapDepositToSwap :exec
|
||||
UPDATE
|
||||
deposits
|
||||
|
|
|
|||
|
|
@ -457,6 +457,23 @@ func (q *Queries) MapDepositToSwap(ctx context.Context, arg MapDepositToSwapPara
|
|||
return err
|
||||
}
|
||||
|
||||
const overrideSelectedSwapAmount = `-- name: OverrideSelectedSwapAmount :exec
|
||||
UPDATE static_address_swaps
|
||||
SET
|
||||
selected_amount = $2
|
||||
WHERE swap_hash = $1
|
||||
`
|
||||
|
||||
type OverrideSelectedSwapAmountParams struct {
|
||||
SwapHash []byte
|
||||
SelectedAmount int64
|
||||
}
|
||||
|
||||
func (q *Queries) OverrideSelectedSwapAmount(ctx context.Context, arg OverrideSelectedSwapAmountParams) error {
|
||||
_, err := q.db.ExecContext(ctx, overrideSelectedSwapAmount, arg.SwapHash, arg.SelectedAmount)
|
||||
return err
|
||||
}
|
||||
|
||||
const swapHashForDepositID = `-- name: SwapHashForDepositID :one
|
||||
SELECT
|
||||
swap_hash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue