loop: expose server grpc connection

pull/632/head
sputn1ck 9 months ago
parent 091c0a86bd
commit 4d558b1418
No known key found for this signature in database
GPG Key ID: 671103D881A5F0E4

@ -19,6 +19,7 @@ import (
"github.com/lightninglabs/loop/sweep" "github.com/lightninglabs/loop/sweep"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
"google.golang.org/grpc"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
@ -148,6 +149,7 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore,
LndServices: cfg.Lnd, LndServices: cfg.Lnd,
Server: swapServerClient, Server: swapServerClient,
Store: loopDB, Store: loopDB,
Conn: swapServerClient.conn,
LsatStore: lsatStore, LsatStore: lsatStore,
CreateExpiryTimer: func(d time.Duration) <-chan time.Time { CreateExpiryTimer: func(d time.Duration) <-chan time.Time {
return time.NewTimer(d).C return time.NewTimer(d).C
@ -200,6 +202,11 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore,
return client, cleanup, nil return client, cleanup, nil
} }
// GetConn returns the gRPC connection to the server.
func (s *Client) GetConn() *grpc.ClientConn {
return s.clientConfig.Conn
}
// FetchSwaps returns all loop in and out swaps currently in the database. // FetchSwaps returns all loop in and out swaps currently in the database.
func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) { func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
loopOutSwaps, err := s.Store.FetchLoopOutSwaps(ctx) loopOutSwaps, err := s.Store.FetchLoopOutSwaps(ctx)

@ -6,12 +6,14 @@ import (
"github.com/lightninglabs/aperture/lsat" "github.com/lightninglabs/aperture/lsat"
"github.com/lightninglabs/lndclient" "github.com/lightninglabs/lndclient"
"github.com/lightninglabs/loop/loopdb" "github.com/lightninglabs/loop/loopdb"
"google.golang.org/grpc"
) )
// clientConfig contains config items for the swap client. // clientConfig contains config items for the swap client.
type clientConfig struct { type clientConfig struct {
LndServices *lndclient.LndServices LndServices *lndclient.LndServices
Server swapServerClient Server swapServerClient
Conn *grpc.ClientConn
Store loopdb.SwapStore Store loopdb.SwapStore
LsatStore lsat.Store LsatStore lsat.Store
CreateExpiryTimer func(expiry time.Duration) <-chan time.Time CreateExpiryTimer func(expiry time.Duration) <-chan time.Time

Loading…
Cancel
Save