From 4d558b14185d73b333099e7b42eb7b740b0df816 Mon Sep 17 00:00:00 2001 From: sputn1ck Date: Fri, 25 Aug 2023 01:41:45 +0200 Subject: [PATCH] loop: expose server grpc connection --- client.go | 7 +++++++ config.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/client.go b/client.go index fedc311..cf54815 100644 --- a/client.go +++ b/client.go @@ -19,6 +19,7 @@ import ( "github.com/lightninglabs/loop/sweep" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/routing/route" + "google.golang.org/grpc" "google.golang.org/grpc/status" ) @@ -148,6 +149,7 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore, LndServices: cfg.Lnd, Server: swapServerClient, Store: loopDB, + Conn: swapServerClient.conn, LsatStore: lsatStore, CreateExpiryTimer: func(d time.Duration) <-chan time.Time { return time.NewTimer(d).C @@ -200,6 +202,11 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore, 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. func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) { loopOutSwaps, err := s.Store.FetchLoopOutSwaps(ctx) diff --git a/config.go b/config.go index 7edba8b..0e2a7b5 100644 --- a/config.go +++ b/config.go @@ -6,12 +6,14 @@ import ( "github.com/lightninglabs/aperture/lsat" "github.com/lightninglabs/lndclient" "github.com/lightninglabs/loop/loopdb" + "google.golang.org/grpc" ) // clientConfig contains config items for the swap client. type clientConfig struct { LndServices *lndclient.LndServices Server swapServerClient + Conn *grpc.ClientConn Store loopdb.SwapStore LsatStore lsat.Store CreateExpiryTimer func(expiry time.Duration) <-chan time.Time