Skip to content

Commit dc5d0fe

Browse files
committed
sweepbatcher: narrow down interface of swapStore
Only one method of loopdb.SwapStore is used (FetchLoopOutSwap). Local interface LoopOutFetcher was defined to reflect this.
1 parent b5b1799 commit dc5d0fe

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

sweepbatcher/sweep_batcher.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ type BatcherStore interface {
8282
TotalSweptAmount(ctx context.Context, id int32) (btcutil.Amount, error)
8383
}
8484

85+
// LoopOutFetcher is used to load LoopOut swaps from the database.
86+
// It is implemented by loopdb.SwapStore.
87+
type LoopOutFetcher interface {
88+
// FetchLoopOutSwap returns the loop out swap with the given hash.
89+
FetchLoopOutSwap(ctx context.Context,
90+
hash lntypes.Hash) (*loopdb.LoopOut, error)
91+
}
92+
8593
// MuSig2SignSweep is a function that can be used to sign a sweep transaction
8694
// cooperatively with the swap server.
8795
type MuSig2SignSweep func(ctx context.Context,
@@ -183,9 +191,8 @@ type Batcher struct {
183191
// batcher and the batches.
184192
store BatcherStore
185193

186-
// swapStore includes all the database interactions that are needed for
187-
// interacting with swaps.
188-
swapStore loopdb.SwapStore
194+
// swapStore is used to load LoopOut swaps from the database.
195+
swapStore LoopOutFetcher
189196

190197
// wg is a waitgroup that is used to wait for all the goroutines to
191198
// exit.
@@ -197,7 +204,7 @@ func NewBatcher(wallet lndclient.WalletKitClient,
197204
chainNotifier lndclient.ChainNotifierClient,
198205
signerClient lndclient.SignerClient, musig2ServerSigner MuSig2SignSweep,
199206
verifySchnorrSig VerifySchnorrSig, chainparams *chaincfg.Params,
200-
store BatcherStore, swapStore loopdb.SwapStore) *Batcher {
207+
store BatcherStore, swapStore LoopOutFetcher) *Batcher {
201208

202209
return &Batcher{
203210
batches: make(map[int32]*batch),

0 commit comments

Comments
 (0)