Skip to content

Commit

Permalink
Merge pull request #761 from starius/sweepbatcher-load-swaps-from-loo…
Browse files Browse the repository at this point in the history
…pdb-only

sweepbatcher/Store: use only own tables (separating from loopdb)
  • Loading branch information
starius authored May 31, 2024
2 parents 6b09aaa + 7a7ea05 commit 37194d3
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 208 deletions.
94 changes: 7 additions & 87 deletions loopdb/sqlc/batch.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions loopdb/sqlc/instantout.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion loopdb/sqlc/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 4 additions & 13 deletions loopdb/sqlc/queries/batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ WHERE
sweeps.swap_hash = $1
AND
sweeps.completed = TRUE
AND
AND
sweep_batches.confirmed = TRUE;

-- name: GetBatchSweptAmount :one
Expand All @@ -91,22 +91,13 @@ AND

-- name: GetBatchSweeps :many
SELECT
sweeps.*,
swaps.*,
loopout_swaps.*,
htlc_keys.*
*
FROM
sweeps
JOIN
swaps ON sweeps.swap_hash = swaps.swap_hash
JOIN
loopout_swaps ON sweeps.swap_hash = loopout_swaps.swap_hash
JOIN
htlc_keys ON sweeps.swap_hash = htlc_keys.swap_hash
WHERE
sweeps.batch_id = $1
batch_id = $1
ORDER BY
sweeps.id ASC;
id ASC;

-- name: GetSweepStatus :one
SELECT
Expand Down
4 changes: 2 additions & 2 deletions loopdb/sqlc/queries/instantout.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- name: InsertInstantOut :exec
INSERT INTO instantout_swaps (
swap_hash,
preimage,
preimage,
sweep_address,
outgoing_chan_set,
htlc_fee_rate,
Expand Down Expand Up @@ -53,7 +53,7 @@ WHERE
swaps.swap_hash = $1;

-- name: GetInstantOutSwaps :many
SELECT
SELECT
swaps.*,
instantout_swaps.*,
htlc_keys.*
Expand Down
12 changes: 6 additions & 6 deletions loopdb/sqlc/queries/swaps.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- name: GetLoopOutSwaps :many
SELECT
SELECT
swaps.*,
loopout_swaps.*,
htlc_keys.*
FROM
FROM
swaps
JOIN
loopout_swaps ON swaps.swap_hash = loopout_swaps.swap_hash
Expand All @@ -13,7 +13,7 @@ ORDER BY
swaps.id;

-- name: GetLoopOutSwap :one
SELECT
SELECT
swaps.*,
loopout_swaps.*,
htlc_keys.*
Expand All @@ -27,7 +27,7 @@ WHERE
swaps.swap_hash = $1;

-- name: GetLoopInSwaps :many
SELECT
SELECT
swaps.*,
loopin_swaps.*,
htlc_keys.*
Expand All @@ -41,7 +41,7 @@ ORDER BY
swaps.id;

-- name: GetLoopInSwap :one
SELECT
SELECT
swaps.*,
loopin_swaps.*,
htlc_keys.*
Expand All @@ -55,7 +55,7 @@ WHERE
swaps.swap_hash = $1;

-- name: GetSwapUpdates :many
SELECT
SELECT
*
FROM
swap_updates
Expand Down
12 changes: 6 additions & 6 deletions loopdb/sqlc/swaps.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions loopout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func testCustomSweepConfTarget(t *testing.T) {

errChan := make(chan error, 2)

batcherStore := sweepbatcher.NewStoreMock(cfg.store)
batcherStore := sweepbatcher.NewStoreMock()

batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
Expand Down Expand Up @@ -530,7 +530,7 @@ func testPreimagePush(t *testing.T) {

errChan := make(chan error, 2)

batcherStore := sweepbatcher.NewStoreMock(cfg.store)
batcherStore := sweepbatcher.NewStoreMock()

batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
Expand Down Expand Up @@ -951,7 +951,7 @@ func TestLoopOutMuSig2Sweep(t *testing.T) {

errChan := make(chan error, 2)

batcherStore := sweepbatcher.NewStoreMock(cfg.store)
batcherStore := sweepbatcher.NewStoreMock()

batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
Expand Down
Loading

0 comments on commit 37194d3

Please sign in to comment.