multi: use context in loopdb call

This commit adds a context to our loopdb interface, which we should use
in the sqlite migration.
This commit is contained in:
sputn1ck 2023-05-16 17:40:52 +02:00
parent 319a519309
commit becc8a38d8
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
15 changed files with 161 additions and 120 deletions

View file

@ -450,7 +450,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}
// Retrieve all currently existing swaps from the database.
swapsList, err := d.impl.FetchSwaps()
swapsList, err := d.impl.FetchSwaps(d.mainCtx)
if err != nil {
if d.macaroonService == nil {
cleanupMacaroonStore()

View file

@ -741,11 +741,11 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
// GetInfo returns basic information about the loop daemon and details to swaps
// from the swap store.
func (s *swapClientServer) GetInfo(_ context.Context,
func (s *swapClientServer) GetInfo(ctx context.Context,
_ *clientrpc.GetInfoRequest) (*clientrpc.GetInfoResponse, error) {
// Fetch loop-outs from the loop db.
outSwaps, err := s.impl.Store.FetchLoopOutSwaps()
outSwaps, err := s.impl.Store.FetchLoopOutSwaps(ctx)
if err != nil {
return nil, err
}
@ -772,7 +772,7 @@ func (s *swapClientServer) GetInfo(_ context.Context,
}
// Fetch loop-ins from the loop db.
inSwaps, err := s.impl.Store.FetchLoopInSwaps()
inSwaps, err := s.impl.Store.FetchLoopInSwaps(ctx)
if err != nil {
return nil, err
}

View file

@ -1,6 +1,7 @@
package loopd
import (
"context"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
@ -42,7 +43,7 @@ func view(config *Config, lisCfg *ListenerCfg) error {
}
func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
swaps, err := swapClient.Store.FetchLoopOutSwaps()
swaps, err := swapClient.Store.FetchLoopOutSwaps(context.Background())
if err != nil {
return err
}
@ -91,7 +92,7 @@ func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
}
func viewIn(swapClient *loop.Client, chainParams *chaincfg.Params) error {
swaps, err := swapClient.Store.FetchLoopInSwaps()
swaps, err := swapClient.Store.FetchLoopInSwaps(context.Background())
if err != nil {
return err
}