Skip to content

Commit de9c17b

Browse files
committed
subservers: add Impl to subservers, GetServer to mgr
1 parent 1d1ac8a commit de9c17b

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

subservers/faraday.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/lightninglabs/faraday/frdrpcserver"
1010
"github.com/lightninglabs/faraday/frdrpcserver/perms"
1111
"github.com/lightninglabs/lndclient"
12+
"github.com/lightninglabs/taproot-assets/fn"
1213
"github.com/lightningnetwork/lnd/lnrpc"
1314
"google.golang.org/grpc"
1415
"gopkg.in/macaroon-bakery.v2/bakery"
@@ -126,3 +127,13 @@ func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
126127
func (f *faradaySubServer) WhiteListedURLs() map[string]struct{} {
127128
return nil
128129
}
130+
131+
// Impl returns the actual implementation of the sub-server. This might not be
132+
// set if the sub-server is running in remote mode.
133+
func (f *faradaySubServer) Impl() fn.Option[any] {
134+
if f.RPCServer == nil {
135+
return fn.None[any]()
136+
}
137+
138+
return fn.Some[any](f.RPCServer)
139+
}

subservers/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
restProxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
77
"github.com/lightninglabs/lndclient"
8+
"github.com/lightninglabs/taproot-assets/fn"
89
"github.com/lightningnetwork/lnd/lnrpc"
910
"github.com/lightningnetwork/lnd/macaroons"
1011
"google.golang.org/grpc"
@@ -62,4 +63,8 @@ type SubServer interface {
6263
// WhiteListedURLs returns a map of all the sub-server's URLs that can
6364
// be accessed without a macaroon.
6465
WhiteListedURLs() map[string]struct{}
66+
67+
// Impl returns the actual implementation of the sub-server. This might
68+
// not be set if the sub-server is running in remote mode.
69+
Impl() fn.Option[any]
6570
}

subservers/loop.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/lightninglabs/loop/loopd"
1010
"github.com/lightninglabs/loop/loopd/perms"
1111
"github.com/lightninglabs/loop/looprpc"
12+
"github.com/lightninglabs/taproot-assets/fn"
1213
"github.com/lightningnetwork/lnd/lnrpc"
1314
"google.golang.org/grpc"
1415
"gopkg.in/macaroon-bakery.v2/bakery"
@@ -136,3 +137,13 @@ func (l *loopSubServer) Permissions() map[string][]bakery.Op {
136137
func (l *loopSubServer) WhiteListedURLs() map[string]struct{} {
137138
return nil
138139
}
140+
141+
// Impl returns the actual implementation of the sub-server. This might not be
142+
// set if the sub-server is running in remote mode.
143+
func (l *loopSubServer) Impl() fn.Option[any] {
144+
if l.Daemon == nil {
145+
return fn.None[any]()
146+
}
147+
148+
return fn.Some[any](l.Daemon)
149+
}

subservers/manager.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ func (s *Manager) AddServer(ss SubServer, enable bool) error {
9090
return nil
9191
}
9292

93+
// GetServer returns the sub-server with the given name if it exists.
94+
func (s *Manager) GetServer(name string) (SubServer, bool) {
95+
s.mu.RLock()
96+
defer s.mu.RUnlock()
97+
98+
ss, ok := s.servers[name]
99+
if !ok {
100+
return nil, false
101+
}
102+
103+
return ss.SubServer, true
104+
}
105+
93106
// StartIntegratedServers starts all the manager's sub-servers that should be
94107
// started in integrated mode.
95108
func (s *Manager) StartIntegratedServers(lndClient lnrpc.LightningClient,

subservers/pool.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/lightninglabs/pool"
99
"github.com/lightninglabs/pool/perms"
1010
"github.com/lightninglabs/pool/poolrpc"
11+
"github.com/lightninglabs/taproot-assets/fn"
1112
"github.com/lightningnetwork/lnd/lnrpc"
1213
"google.golang.org/grpc"
1314
"gopkg.in/macaroon-bakery.v2/bakery"
@@ -126,3 +127,13 @@ func (p *poolSubServer) Permissions() map[string][]bakery.Op {
126127
func (p *poolSubServer) WhiteListedURLs() map[string]struct{} {
127128
return nil
128129
}
130+
131+
// Impl returns the actual implementation of the sub-server. This might not be
132+
// set if the sub-server is running in remote mode.
133+
func (p *poolSubServer) Impl() fn.Option[any] {
134+
if p.Server == nil {
135+
return fn.None[any]()
136+
}
137+
138+
return fn.Some[any](p.Server)
139+
}

subservers/taproot-assets.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/lightninglabs/lndclient"
1010
tap "github.com/lightninglabs/taproot-assets"
1111
"github.com/lightninglabs/taproot-assets/address"
12+
"github.com/lightninglabs/taproot-assets/fn"
1213
"github.com/lightninglabs/taproot-assets/perms"
1314
"github.com/lightninglabs/taproot-assets/tapcfg"
1415
"github.com/lightninglabs/taproot-assets/taprpc"
@@ -177,6 +178,20 @@ func (t *taprootAssetsSubServer) RegisterRestService(ctx context.Context,
177178
return err
178179
}
179180

181+
err = rfqrpc.RegisterRfqHandlerFromEndpoint(
182+
ctx, mux, endpoint, dialOpts,
183+
)
184+
if err != nil {
185+
return err
186+
}
187+
188+
err = tchrpc.RegisterTaprootAssetChannelsHandlerFromEndpoint(
189+
ctx, mux, endpoint, dialOpts,
190+
)
191+
if err != nil {
192+
return err
193+
}
194+
180195
err = universerpc.RegisterUniverseHandlerFromEndpoint(
181196
ctx, mux, endpoint, dialOpts,
182197
)
@@ -239,3 +254,13 @@ func (t *taprootAssetsSubServer) WhiteListedURLs() map[string]struct{} {
239254
t.cfg.RpcConf.AllowPublicStats || t.remote,
240255
)
241256
}
257+
258+
// Impl returns the actual implementation of the sub-server. This might not be
259+
// set if the sub-server is running in remote mode.
260+
func (t *taprootAssetsSubServer) Impl() fn.Option[any] {
261+
if t.Server == nil {
262+
return fn.None[any]()
263+
}
264+
265+
return fn.Some[any](t.Server)
266+
}

0 commit comments

Comments
 (0)