Skip to content

Commit 9d7b2c5

Browse files
committed
subservers: add Impl to subservers, GetServer to mgr
1 parent 7055689 commit 9d7b2c5

File tree

6 files changed

+61
-0
lines changed

6 files changed

+61
-0
lines changed

subservers/faraday.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
126126
func (f *faradaySubServer) WhiteListedURLs() map[string]struct{} {
127127
return nil
128128
}
129+
130+
// Impl returns the actual implementation of the sub-server. This might not be
131+
// set if the sub-server is running in remote mode.
132+
func (f *faradaySubServer) Impl() any {
133+
return f.RPCServer
134+
}

subservers/interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ type SubServer interface {
6262
// WhiteListedURLs returns a map of all the sub-server's URLs that can
6363
// be accessed without a macaroon.
6464
WhiteListedURLs() map[string]struct{}
65+
66+
// Impl returns the actual implementation of the sub-server. This might
67+
// not be set if the sub-server is running in remote mode.
68+
Impl() any
6569
}

subservers/loop.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,9 @@ func (l *loopSubServer) Permissions() map[string][]bakery.Op {
136136
func (l *loopSubServer) WhiteListedURLs() map[string]struct{} {
137137
return nil
138138
}
139+
140+
// Impl returns the actual implementation of the sub-server. This might not be
141+
// set if the sub-server is running in remote mode.
142+
func (l *loopSubServer) Impl() any {
143+
return l.Daemon
144+
}

subservers/manager.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ func (s *Manager) AddServer(ss SubServer, enable bool) {
7878
s.statusServer.SetEnabled(ss.Name())
7979
}
8080

81+
// GetServer returns the sub-server with the given name if it exists.
82+
func (s *Manager) GetServer(name string) (SubServer, bool) {
83+
s.mu.RLock()
84+
defer s.mu.RUnlock()
85+
86+
for _, ss := range s.servers {
87+
if ss.Name() == name {
88+
return ss.SubServer, true
89+
}
90+
}
91+
92+
return nil, false
93+
}
94+
8195
// StartIntegratedServers starts all the manager's sub-servers that should be
8296
// started in integrated mode.
8397
func (s *Manager) StartIntegratedServers(lndClient lnrpc.LightningClient,

subservers/pool.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ func (p *poolSubServer) Permissions() map[string][]bakery.Op {
126126
func (p *poolSubServer) WhiteListedURLs() map[string]struct{} {
127127
return nil
128128
}
129+
130+
// Impl returns the actual implementation of the sub-server. This might not be
131+
// set if the sub-server is running in remote mode.
132+
func (p *poolSubServer) Impl() any {
133+
return p.Server
134+
}

subservers/taproot-assets.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/lightninglabs/taproot-assets/taprpc"
1313
"github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
1414
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
15+
"github.com/lightninglabs/taproot-assets/taprpc/rfqrpc"
16+
tchrpc "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc"
1517
"github.com/lightninglabs/taproot-assets/taprpc/universerpc"
1618
"github.com/lightningnetwork/lnd/lnrpc"
1719
"google.golang.org/grpc"
@@ -45,6 +47,7 @@ func NewTaprootAssetsSubServer(cfg *tapcfg.Config,
4547
tap.SetAgentName("litd")
4648

4749
return &taprootAssetsSubServer{
50+
Server: tap.NewServer(nil),
4851
cfg: cfg,
4952
remoteCfg: remoteCfg,
5053
remote: remote,
@@ -116,6 +119,8 @@ func (t *taprootAssetsSubServer) RegisterGrpcService(
116119
taprpc.RegisterTaprootAssetsServer(registrar, t)
117120
mintrpc.RegisterMintServer(registrar, t)
118121
assetwalletrpc.RegisterAssetWalletServer(registrar, t)
122+
rfqrpc.RegisterRfqServer(registrar, t)
123+
tchrpc.RegisterTaprootAssetChannelsServer(registrar, t)
119124
universerpc.RegisterUniverseServer(registrar, t)
120125
}
121126

@@ -148,6 +153,20 @@ func (t *taprootAssetsSubServer) RegisterRestService(ctx context.Context,
148153
return err
149154
}
150155

156+
err = rfqrpc.RegisterRfqHandlerFromEndpoint(
157+
ctx, mux, endpoint, dialOpts,
158+
)
159+
if err != nil {
160+
return err
161+
}
162+
163+
err = tchrpc.RegisterTaprootAssetChannelsHandlerFromEndpoint(
164+
ctx, mux, endpoint, dialOpts,
165+
)
166+
if err != nil {
167+
return err
168+
}
169+
151170
err = universerpc.RegisterUniverseHandlerFromEndpoint(
152171
ctx, mux, endpoint, dialOpts,
153172
)
@@ -209,3 +228,9 @@ func (t *taprootAssetsSubServer) WhiteListedURLs() map[string]struct{} {
209228
t.cfg.RpcConf.AllowPublicStats || t.remote,
210229
)
211230
}
231+
232+
// Impl returns the actual implementation of the sub-server. This might not be
233+
// set if the sub-server is running in remote mode.
234+
func (t *taprootAssetsSubServer) Impl() any {
235+
return t.Server
236+
}

0 commit comments

Comments
 (0)