Commit Graph

27 Commits (lnd-18-preparation)

Author SHA1 Message Date
Boris Nagaev 0c2ba74dba
sweepbatcher: factor out loopdb-less version
Changed argument of function NewBatcher from LoopOutFetcher to SweepFetcher
(returning new public type SweepInfo).
This change is backwards-incompatible on the package layer, but nobody seems
to use the package outside of Loop.

To use NewBatcher inside Loop, turn loopdb into SweepFetcher using
function NewSweepFetcherFromSwapStore.
7 days ago
Boris Nagaev 7a7ea05e52
sweepbatcher/Store: do not provide LoopOut field
This data is not used by Batcher since commit
"sweepbatcher: load swap from loopdb, not own store".

Now sweepbatcher.Store depends only on tables sweeps and sweep_batches
and does not depend on swaps, loopout_swaps and htlc_keys, making it
easier to reuse.
1 week ago
Boris Nagaev 4be69e186e
Revert "sweepbatcher/StoreMock: load LoopOut from loopdb"
This reverts commit d38b7c55a7.

Batcher does not use this data anymore, since previous commit.
1 week ago
Boris Nagaev 16132d1593
sweepbatcher: load swap from loopdb, not own store
Method Store.GetBatchSweeps provides data from tables outside of sweepbatcher:
swaps, loopout_swaps, htlc_keys. It makes it harder to reuse. Batcher already
has a straightforward way to get swap data: LoopOutFetcher interface (loopdb).

In this commit I switch the source of data from the field returned by Store
(LoopOut) to loading independently by calling LoopOutFetcher.FetchLoopOutSwap.
1 week ago
Slyghtning 402d9a84df
gomod: bump lnd to version 0.18.0-beta 2 weeks ago
Boris Nagaev 87fb185a9b
sweepbatcher: remove const defaultBatchConfTarget
It is always overwritten with primary sweep's confTarget.

Print a warning if batchConfTarget is 0 in updateRbfRate.

See https://github.com/lightninglabs/loop/pull/754#discussion_r1613514363
2 weeks ago
Boris Nagaev 40ad1ce609
sweepbatcher: load from DB preserves confTarget
It used to be set to default (defaultBatchConfTarget = 12) which
could in theory affect fee rate if updateRbfRate() and publish()
were not called before the batch was saved. (Unlikely scenario.)
2 weeks ago
Boris Nagaev d38b7c55a7
sweepbatcher/StoreMock: load LoopOut from loopdb
Method sweepbatcher.Store.FetchBatchSweeps (implementation using real DB) runs
JOIN query to load LoopOut from swaps table. Now the mock does the same.

It is needed to test store and load scenarios in tests.
2 weeks ago
Boris Nagaev 4258b95dd2
sweepbatcher: fix too long lines 2 weeks ago
Boris Nagaev 0b2c177445
sweepbatcher: exit early in handleSweep
If the sweep was successfully updated in the batch, no need to
try to add it to all other batches.

Added a test reproducing adding a sweep to both batches without this change.
2 weeks ago
Boris Nagaev 870b60fada
sweepbatcher: fix docstring 2 weeks ago
Boris Nagaev 6def712dfe
sweepbatcher: fix typos in annotations of methods 2 weeks ago
Boris Nagaev dc5d0fe30c
sweepbatcher: narrow down interface of swapStore
Only one method of loopdb.SwapStore is used (FetchLoopOutSwap).
Local interface LoopOutFetcher was defined to reflect this.
2 weeks ago
Boris Nagaev b5b17991a5
sweepbatcher: use method AddSweep in test 2 weeks ago
Andras Banki-Horvath 14de8f1f5d
sweepbatcher: test that empty batches won't prevent startup 2 weeks ago
Andras Banki-Horvath e5ade6a0b1
sweepbatcher: close the quit channel when the batcher is shutting down 2 weeks ago
Andras Banki-Horvath c01e8014e1
sweepbatcher: do not fail on restoring empty batches
Previously storing an empty batch would make the batcher fail to start
as spinning up a restored batch assumes that there's a primary sweep
added already. As there's no point in spinning up such batch we can just
skip over it.
Furthermore we'll ensure that we won't try to ever publish an empty
batch to avoid setting the fee rate too early.
2 weeks ago
Andras Banki-Horvath 939c9b4ccf
loopdb+sweepbatcher: add the DropBatch call 2 weeks ago
Andras Banki-Horvath 56902352cd
loopout: fix negative reported fees 3 weeks ago
Andras Banki-Horvath 75d7641d74
sweepbatcher: add more debug logging 1 month ago
Andras Banki-Horvath e1ddb50dfe
loopout+sweepbatcher: calculate the per sweep onchain fees correctly
Previously we'd report the fees per sweep as the total sweep cost of a
batch. With this change the reported cost will be the proportional fee
which should be equal for all sweeps except if there's any rounding
difference in which case that is paid by the sweep belonging to the
first input of the batch tx.
3 months ago
Andras Banki-Horvath b4ebb19a77
loopdb+sweepbatcher: add GetParentBatch and TotalSwept calls 3 months ago
Andras Banki-Horvath c094ad4a85
sweepbatcher: refactor monitorSpendAndNotify to return an error 3 months ago
George Tsagkarelis 849d26bba6
sweepbatcher: add batcher tests 5 months ago
George Tsagkarelis 7081fb7aae
sweepbatcher: add sweep batcher 5 months ago
George Tsagkarelis 56784ab921
sweepbatcher: add sweep batch 5 months ago
George Tsagkarelis 99608ad515
loopdb+sweepbatcher: add sweepbatcher store 5 months ago